how to read line by line from database
sql database in c#how to read line by line from database
Page 1 of 1
1 Replies - 957 Views - Last Post: 24 August 2009 - 04:40 AM
Replies To: sql database in c#
#2
Re: sql database in c#
Posted 24 August 2009 - 04:40 AM
dharshinfotech, on 24 Aug, 2009 - 06:31 AM, said:
how to read line by line from database
for me, it's easiest to use the SqlConnection, SqlCommand, and SqlDataReader classes.
using (SqlConnection conn = new SqlConnection(yourConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
// your command code(connection, query, etc.)
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
//process the current data
// if the first column is a string type
string someData = dr.GetString(0);
}
}
}
}
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|