14
Answers

C#.net store procedure not inserting data to sql database

Amy Turnbull

Amy Turnbull

17y
8.7k
1
Hello, I have run and excute and tested my sql procedures and they work, but in my code its not working and the values are correct, can you see if im missing anything pleae.

private void CheckOut_Click(object sender, System.EventArgs e)
{
string myConnectionString = (string) ConfigurationSettings.AppSettings["SqlConnection"];

 // create connection
SqlConnection cnn = new SqlConnection(myConnectionString);

// create command SqlCommand cmd = cnn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "BugTrackerInsertCheckedOut";

// add parameters
cmd.Parameters.Add(new SqlParameter("@bg_id", SqlDbType.Int)); cmd.Parameters["@bg_id"].Value = id;
cmd.Parameters.Add(new SqlParameter("@us_id", SqlDbType.Int)); cmd.Parameters["@us_id"].Value = security.this_usid;

// execute and close cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close(); }
Answers (14)