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?

Re: Generated Insert Command from CommandBuilder by Sahil

Sahil
Fri Oct 22 10:34:28 CDT 2004

Yes, the CommandText property will give you the text.

And much to your chagrin as you will see CommandBuilder generates a hyper
inefficient command too.

- Sahil Malik
http://www.dotnetjunkies.com/weblog/sahilmalik
Please reply to the newsgroups instead of email so everyone can benefit from
your reply.


"mh1mark" <mh1mark@discussions.microsoft.com> wrote in message
news:49828AF0-FACB-4C68-B01F-4E25B9B5ADBB@microsoft.com...
> 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?



Re: Generated Insert Command from CommandBuilder by Miha

Miha
Fri Oct 22 11:07:14 CDT 2004

Hi,

Just a suggestion:
You should avoid using commandbuilder.
Instead build your adapters manually or at design time using a wizard.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"mh1mark" <mh1mark@discussions.microsoft.com> wrote in message
news:49828AF0-FACB-4C68-B01F-4E25B9B5ADBB@microsoft.com...
> 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?



Re: Generated Insert Command from CommandBuilder by Mike

Mike
Fri Oct 22 11:10:46 CDT 2004

mh1mark wrote:
> 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

Re: Generated Insert Command from CommandBuilder by David

David
Fri Oct 22 13:33:57 CDT 2004


"mh1mark" <mh1mark@discussions.microsoft.com> wrote in message
news:49828AF0-FACB-4C68-B01F-4E25B9B5ADBB@microsoft.com...
> 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



Re: Generated Insert Command from CommandBuilder by Nieurig

Nieurig
Tue Oct 26 01:37:03 CDT 2004

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