Generated Insert Command from CommandBuilder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having some trouble with an insert back to a datasource using the the
insertcommand built by commandbuilder. I suspect it may be a slight problem
with the insert statement. Is there any way to see the actual insert
statement that commandbuilder creates?
 
Hi,

Just a suggestion:
You should avoid using commandbuilder.
Instead build your adapters manually or at design time using a wizard.
 
mh1mark said:
I'm having some trouble with an insert back to a datasource using the the
insertcommand built by commandbuilder. I suspect it may be a slight problem
with the insert statement. Is there any way to see the actual insert
statement that commandbuilder creates?

The SQL statement is assigned to the CommandText of the DataAdapter's
InsertCommand:

dataAdapeter1.InsertCommand.CommandText

Additionally, you can run the CommandBuilder at design time by dragging
a new data adapter onto your form and letting it generate the SQL for
you. The code should be identical to what gets generated at runtime.

--Mike
 
mh1mark said:
I'm having some trouble with an insert back to a datasource using the the
insertcommand built by commandbuilder. I suspect it may be a slight
problem
with the insert statement. Is there any way to see the actual insert
statement that commandbuilder creates?

....
xxxDataAdapter da = new xxxDataAdapter(cmd);
xxxCommandBuilder cb = new xxxCommandBuilder(da);
Console.WriteLine(cb.CreateInsertCommand().CommandText);

David
 
Hi,
i had the same problem after controlling the generated visual because i dont
see that one fieldname was a reserve sql-Statement.

After using the suffix and prefix - property of the builder all fields was
written in "[" an "]" an the statement runs perfekt.

Niels
 
Back
Top