Something like this (notice I didn't include
try/catch/finally
block):
SqlConnection conn = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand("proc_udatabase", conn);
SqlDataReader reader = null;
Datatable data = new DataTable();
conn.Open();
cmd.Parameters.Add(new SqlParameter("@string1", "name");
cmd.Parameters.Add(new SqlParameter("@string2", "24");
reader = cmd.ExecuteReader();
if (reader != null)
{
data.Load(reader);
}
conn.Close();