Question Locked

Why should I use ADO?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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.

2 replies

by tony hopkinson

tuned up to be specific to MS SQL
If that's all you do and are going to connect to it's what you should use.

This discussion is closed to new replies.