Fill .NET Listbox with SQL DataReader

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 24
January 01, 2003
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Fill .NET Listbox with SQL DataReader


<%@ Import Namespace="System.Data.SQLClient" %>
<script language=VB runat=server>
Sub Page_Load(Sender As Object, E As EventArgs)
Dim conn As SqlConnection =
New SqlConnection(ConfigurationSettings.AppSettings("DSN_pubs")) Dim sql as string =
"Select au_id, au_lname, au_fname from Authors" Dim dr as New SQLCommand(sql, conn) Dim reader as sqldatareader Dim values as ArrayList= new ArrayList() conn.Open() reader = dr.ExecuteReader() While reader.Read() Values.Add(reader.item("au_id").ToString()) End While lb.DataSource = values lb.DataBind() conn.Close() reader.close() End Sub </script> <html> <head> <title>ListBox using SQLDataReader</title> </head> <body> <form method="post" runat="server"> <asp:ListBox id="lb" SelectionMode="Multiple" runat="server"/> </form> </body> </html>
blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials