Saving a dataset back to source

  • Thread starter Thread starter Karl
  • Start date Start date
K

Karl

Hi,

I am having trouble trying to save my updated dataset back
to the source db.

The dataset has 6 tables that I need to cache and work
with and then use stored procedures to insert back into
the db.

below is my command object set up, please tell me if this
is wrong:
public SqlCommand GetInsertCommand(string storedProcName,
SqlConnection conn )
{
SqlCommand aCommand = new
SqlCommand (storedProcName, conn ) ;

aCommand.CommandText =
storedProcName;
aCommand.CommandType =
CommandType.StoredProcedure ;
aCommand.Parameters.Add (new
SqlParameter ("@prm1" , SqlDbType.Decimal, 50, "prm1" ) ) ;
aCommand.Parameters.Add (new
SqlParameter ("@prm2" , SqlDbType.Decimal, 50, "prm2" ) ) ;
aCommand.UpdatedRowSource =
UpdateRowSource.OutputParameters ;
return aCommand ;
}
 
Hi Karl,

To check the command you might do the following:
At design time, drag & drop the stored procedure from Server Explorer window
on the form.
The form designer will then generate appropriate code for you.
In this way you can compare it with your version.
 
Back
Top