How can i define InsertCommand in SQLDataAdapter?

  • Thread starter Thread starter Lubo¹ ©lapák
  • Start date Start date
L

Lubo¹ ©lapák

Hi,
I need define InsertCommand in SQLDataAdapter, but I don't know how. Please
Help me. I don't know the format of InsertCommand.

Thanks
 
The Adapter has an .InsertCommand Property that will allow you do specify
the command you want to use

string sql = "Insert into blah blah blah values @blah, @blah1, @blah2";
SqlCommand cmd = new SqlCommand(sql, connection);
myDataAdapter.InsertCommand = cmd;

Is the problem you're having otherwise with the parameters? I'd recommend
using the configuration wizard on a table that you know has a primary key -
just pick 5 or 6 fields. Then walk through the wizard and hit finish. It
should tell you it generated the statements for each command. Then just
look at it in the code window - it's a bit verbose but will give you a
pretty good idea for what happened.
 
Back
Top