.

Simplest way to execute a SQL query

using (var conn = new SqlConnection("server=.;database=mydatabase;integrated security=yes"))
using (var cmd = new SqlCommand("select count(*) from dbo.Patients", conn))
{
//cmd.Parameters.AddWithValue("@gender", "male");  // just example if needed
conn.Open();
var results = cmd.ExecuteReader();
}

What's your thoughts on this?

*

Protected by WP Anti Spam