Talk:DataReader
Appearance
| This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
Sample code suggestion
[edit]I suggest the following example (please note the additional using for mycommand and avoiding string concatenation):
void DataTest()
{
using (SqlConnection conn1 = new SqlConnection(...))
{
conn1.Open();
using (SqlCommand mycommand = new SqlCommand("Select * From someTable", conn1))
using (SqlDataReader myreader = mycommand.ExecuteReader())
{
if(myreader == null)
{
return;
}
while(myreader.Read())
{
Console.WriteLine(string.Format("{0}:{1}", myreader.GetValue(0), myreader.GetTypeName(0));
}
}
}
}
What do other's think? --Blue4k (talk) 17:49, 23 December 2010 (UTC)
- I like it! Much clearer! Wikipedia:Be bold 5.10.169.18 (talk) 14:36, 6 February 2013 (UTC)
Categories:
- Start-Class Computing articles
- Low-importance Computing articles
- Start-Class software articles
- Low-importance software articles
- Start-Class software articles of Low-importance
- All Software articles
- All Computing articles
- Start-Class Microsoft articles
- Low-importance Microsoft articles
- Start-Class .NET articles
- Low-importance .NET articles
- WikiProject .NET articles
- WikiProject Microsoft articles

