Why should I use ADO? - TechRepublic
Question
March 3, 2010 at 12:12 AM
sara_h

Why should I use ADO?

by sara_h . Updated 16 years, 4 months ago

Hi,
I don’t know why I should use
ADO, when I can use SqlConnection,
and execute multiple commands with
it and it is faster than using ADO, like the code below:

using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[“Item”].ConnectionString))
{
connection.Open();
string strSQL;

strSQL = “select distinct name from Item”;
using (SqlCommand command = new SqlCommand(strSQL, connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
name.DataSource = reader;
name.DataBind();
}
}

strSQL = “select distinct cost from Item”;
using (SqlCommand command = new SqlCommand(strSQL, connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
cost.DataSource = reader;
cost.DataBind();
}
}

strSQL = “select distinct count from Item”;
using (SqlCommand command = new SqlCommand(strSQL, connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
count.DataSource = reader;
count.DataBind();
}
}
connection.Close();
}
Thanks.

This discussion is locked

All Comments