Question

Locked

Why should I use ADO?

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

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Back to Software Forum
2 total posts (Page 1 of 1)  

Software Forums