Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SqlDataReader in a Data Class
Message
From
27/10/2004 10:04:00
 
 
To
27/10/2004 05:43:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Web forms
Environment versions
Environment:
ASP.NET
OS:
Windows 2000 SP3
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00954589
Message ID:
00954848
Views:
17
Unfortunately, this isn't multi-tiered, Cetin, since you have your DataAccess directly in your UI. Tom was looking for a multi-tiered solution.

~~Bonnie


>>I have a multi tiered application I am working on and want to know the following:
>>
>>Using C#, can you create procedure in your data class using a SqlDataReader? I want to fill a drop down list. This is easy to due with a DataSet. Can anyone give me or point me to an example of using a SqlDataReader in a data class?
>>
>>Thank you.
>>
>>Tom
>
>IMHO it's also a correct way for static lists.
>
>private void fillMyCombo()
>{
>  SqlConnection cn = new SqlConnection(
>    "Persist Security Info=False;Integrated Security=SSPI;database=pubs;server=localhost");
>  cn.Open() ;
>  SqlDataReader rdr = new
>   SqlCommand("select * from authors",cn).ExecuteReader(CommandBehavior.CloseConnection);
>  while (rdr.Read())
>  {
>    myCombo.Items.Add(String.Format("{0},{1}",rdr["au_fname"],rdr["au_lname"]));
>  }
>  cn.Close();
>}
>
Cetin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform