Header Ads

Fill dataset using stored procedures

SqlConnection sqlCon = new SqlConnection("ConnectionString");
SqlCommand cmd = new SqlCommand("sp_Name", sqlCon);
sqlCon.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Param1", "Value1");
cmd.Parameters.Add("@Param2", "");
SqlDataAdapter sqlAdapter = new SqlDataAdapter();
sqlAdapter.SelectCommand = cmd;
DataSet ds = new DataSet();
sqlAdapter.Fill(ds);
sqlAdapter.Dispose();
sqlCon.Close();
sqlCon.Dispose();

No comments:



Powered by Blogger.