Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SqlDataReader in a Data Class
Message
De
27/10/2004 10:04:00
 
 
À
27/10/2004 05:43:58
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Versions des environnements
Environment:
ASP.NET
OS:
Windows 2000 SP3
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00954589
Message ID:
00954848
Vues:
18
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform