K
K Viltersten
Today, i run the code below and while it
works, i can't stop wondering if it can
be performed in a better way. Especially,
i'd like to know if the declaration of
the adapter is neccessary.
SqlCommand command =
new SqlCommand("MyStorProc", Connection);
command.CommandType = CommandType.StoredProcedure;
foreach (String key in form.Keys)
command.Parameters.AddWithValue("@" + key, form[key]);
Connection.Open();
command.ExecuteNonQuery();
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet data = new DataSet();
adapter.Fill(data);
Connection.Close();
Can i pull the data directly from command
and if so, how?
works, i can't stop wondering if it can
be performed in a better way. Especially,
i'd like to know if the declaration of
the adapter is neccessary.
SqlCommand command =
new SqlCommand("MyStorProc", Connection);
command.CommandType = CommandType.StoredProcedure;
foreach (String key in form.Keys)
command.Parameters.AddWithValue("@" + key, form[key]);
Connection.Open();
command.ExecuteNonQuery();
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet data = new DataSet();
adapter.Fill(data);
Connection.Close();
Can i pull the data directly from command
and if so, how?