Hi all,
I have a page on which I've done several successful ExecuteNonQuery calls that added new rows to existing tables. But one, despite all the parameters being correct and receiving a positive return value and also a valid output parameter, seems to have no effect on the database. Several tables should have new rows, but none of them do. I'm using similar code for all database calls. Here's the ADO code:
SqlConnection con = GetConnection();
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "spAddTask";
cmd.Parameters.Add("@RequestorID", SqlDbType.Int).Value = ddlRequestors.SelectedValue;
cmd.Parameters.Add("@ReportTopicID", SqlDbType.Int).Value = ddlReportTopics.SelectedValue;
cmd.Parameters.Add("@BusinessTypeID", SqlDbType.Int).Value = ddlBusinessTypes.SelectedValue;
cmd.Parameters.Add("@DueDate", SqlDbType.DateTime).Value = txtDueDate.Text;
cmd.Parameters.Add("@Priority", SqlDbType.VarChar).Value = ddlPriority.SelectedValue;
cmd.Parameters.Add("@RequestorNarration", SqlDbType.VarChar).Value = txtDescription.Text;
SqlParameter prmTaskID = cmd.Parameters.Add("@TaskID", SqlDbType.Int);
prmTaskID.Direction = ParameterDirection.Output;
con.Open();
int z = cmd.ExecuteNonQuery(); //Returns 2
con.Close();
int taskID = Convert.ToInt32(prmTaskID.Value);
}
Any idea of how this can happen? Thanks in advance.
-Eric