Questions

Why should I use ADO?

+
0 Votes
Locked

Why should I use ADO?

sara_h
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.