C#: Is this the correct way to use the SqlDataReader for DAAB
Posted
by Luke101
on Stack Overflow
See other posts from Stack Overflow
or by Luke101
Published on 2010-04-06T16:54:17Z
Indexed on
2010/04/06
17:03 UTC
Read the original article
Hit count: 673
Hello, I have just started using the Data Access Application Block from microsoft. There are very few instructions on the correct way to use the library. Just wanted to know if this is the correct way to use the data reader.
SqlDataReader reader = SqlHelper.ExecuteReader(config.ConnectionString, CommandType.Text, "select * from category");
List<string> a = new List<string>();
using (reader)
{
while (reader.Read())
{
string t = reader.GetString(1);
a.Add(t);
}
return a;
}
will everything get closed doing it this way? Is there any chance of memory leaks?
© Stack Overflow or respective owner