This post says about how to read data from SQL
string oCommand = "Select * from Table";
SqlConnection connection = new SqlConnection(ConnectionString);
using (connection)
{
SqlCommand command = new SqlCommand(oCommand,connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
// use reader.GetString(0) to read the data
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
}
string oCommand = "Select * from Table";
SqlConnection connection = new SqlConnection(ConnectionString);
using (connection)
{
SqlCommand command = new SqlCommand(oCommand,connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
// use reader.GetString(0) to read the data
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
}
No comments:
Post a Comment