Hello,
I'm trying to update my database using the Update command.
By debugging I realized that the parameters are not being passed to the
stored procedure. All parameter values show with value = undefined, except
for EmployeeID, dtpDate and AreaReferenceID which are 2 combos and one date
time picker outside the grid. All parameters which datasource is in the grid
fail. No exception or error message is displayed. but nothing happens at
all..
the code:
private void btnSave_Click(object sender, System.EventArgs e)
{
// Commandos para el adaptador.
SqlConnection strConn = new SqlConnection(strConnection);
SqlCommand sqlUpdate = new SqlCommand("p_UpdateTimeRecording", strConn);
sqlUpdate.CommandType = CommandType.StoredProcedure;
sqlUpdate.Parameters.Add("@TimeRecordingID",SqlDbType.UniqueIdentifier, 0,
"TimeRecordingID");
sqlUpdate.Parameters.Add("@EmployeeID", cboName.SelectedValue.ToString());
sqlUpdate.Parameters.Add("@TRDate", dtpDate.Value);
sqlUpdate.Parameters.Add("@ProjectID", SqlDbType.UniqueIdentifier,0,
"ProjectID");
sqlUpdate.Parameters.Add("@TRActivityID", SqlDbType.UniqueIdentifier,0,
"TRActivityID");
sqlUpdate.Parameters.Add("@OfferID", SqlDbType.UniqueIdentifier,0, "OfferID");
sqlUpdate.Parameters.Add("@CTSAPID", SqlDbType.UniqueIdentifier,0, "CTSAPID");
sqlUpdate.Parameters.Add("@CaseNoID", SqlDbType.UniqueIdentifier,0,
"CaseNoID");
sqlUpdate.Parameters.Add("@Hours", SqlDbType.Real , 4 , "Hours");
sqlUpdate.Parameters.Add("@Comments", SqlDbType.Char, 235, "Comments");
sqlUpdate.Parameters.Add("@AreaReferenceID",
cboArea.SelectedValue.ToString());
daTimeRecording.UpdateCommand = sqlUpdate;
try
{
daTimeRecording.Update(dsTimeRecording.Tables["TimeRecording"]);
dsTimeRecording.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show( ex.ToString());
}
}
Thx a lot! I hope someone can help =)
pls reply only to newsgroup
Sijin Joseph - 20 Nov 2004 05:58 GMT
Make sure that the column names in the dataset match excatly with what
you have given in the Prameters.Add() method.
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> Hello,
> I'm trying to update my database using the Update command.
[quoted text clipped - 43 lines]
> Thx a lot! I hope someone can help =)
> pls reply only to newsgroup
Jim Hughes - 21 Nov 2004 04:16 GMT
All of the parameters you mentioned that are working have valid values
assigned, but why are you quoting the fourth argument in most of the lines
like this one?
sqlUpdate.Parameters.Add("@OfferID", SqlDbType.UniqueIdentifier,0,
"OfferID");
In this case it is trying to set the @OfferID parameter value to the literal
text "OfferID" instead of a UniqueIdentifier value.
Remove the quotes!
> Hello,
> I'm trying to update my database using the Update command.
[quoted text clipped - 47 lines]
> Thx a lot! I hope someone can help =)
> pls reply only to newsgroup