CommandBuilder Problem

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I am using ADOX to create an Access table and populate it with one row of
data. The ADOX code sets two columns as primary keys (I can view the table
in Access and see that they are set). When I try to create the UpdateCommand
I get an error that it fails because the Select does not include a primay
key field (the select is "Select * From tablea"). The relavent code is shown
below.

Any ideas on what I am doing wrong are appreciated.

========================================
Dim cmdBldr As New OleDb.OleDbCommandBuilder(da1)

da1.InsertCommand = cmdBldr.GetInsertCommand

da1.UpdateCommand = cmdBldr.GetUpdateCommand

da1.DeleteCommand = cmdBldr.GetDeleteCommand

================================================

Wayne
 
Oops,

I forgot to tell, in those cases as this I use an SQL insertcommand with an
executenonquery.

In this case it is a little bit strange to use a dataadapter.

Cor
 
Cor;

Thanks for that information. I'll add the fillschema command and try again.

Wayne
 
Don't assign the data adapter's commands to the result of calling those
methods on the command builder.

Creating the command builder on the adapter is enough. Those
GetInsertCommand type methods are for troubleshooting purpose, you are not
supposed to call them and assign the result to the dataadapter.
 
Back
Top