Amy Turnbull

Amy Turnbull

  • NA
  • 40
  • 0

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

Aug 9 2007 11:30 AM
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)