[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Kristin

11/21/2002 11:14:00 PM

2 Answers

(Hussein Abuthuraya(MSFT))

11/23/2002 3:29:00 AM

0

Kristin,

To retreive the Insert/Update/Delete commands that are Auto-Generated from the commandBuilder, you use the CommandBuilder object's
GetInsertCommand/GetUpdateCommand/GetDeleteCommand methods. Here is an example:

Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(daOledb1)
MessageBox.Show(cb.GetInsertCommand.CommandText)

Now, as far as defining the InsertCommand manually, then you need also to define all the parameters to replace all ? marks. For example:

catDA.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NChar, 15, "CategoryName");

If the oleDbCommandBuilder fails to build these commands automatically then you must have a reserved word or special characters in your field names or table name. You
may set QuotePrefix and QuoteSuffix properties of the CommandBuilder object to "[" and "]".

I hope this helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....


Kristin

11/25/2002 12:10:00 AM

0

> If the oleDbCommandBuilder fails to build these commands automatically
then
> you must have a reserved word or special characters in your field names or
table name. ...

This was the problem. One of my field names was "Value" which made the
Update method on the DB association unhappy. A better exception than
"Syntax error in INSERT INTO command." would have been handy.

Thanks for your help!
Kristin