PC Review


Reply
Thread Tools Rate Thread

CommandBuilder Problem

 
 
Wayne Wengert
Guest
Posts: n/a
 
      25th Sep 2005
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


 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      26th Sep 2005
Wayne,

Luckily I started to understand what you where doing, nowhere you told that
you was after creating using AdoNet instead of ADOX.

If you have created the table, than you have at least to create a SQL
statement, and do a fillschema command

http://msdn.microsoft.com/library/de...chematopic.asp

I hope this helps,

Cor


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      26th Sep 2005
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


 
Reply With Quote
 
Wayne Wengert
Guest
Posts: n/a
 
      26th Sep 2005
Cor;

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

Wayne

"Cor Ligthert [MVP]" <(E-Mail Removed)> wrote in message
news:eGvv%(E-Mail Removed)...
> Wayne,
>
> Luckily I started to understand what you where doing, nowhere you told
> that you was after creating using AdoNet instead of ADOX.
>
> If you have created the table, than you have at least to create a SQL
> statement, and do a fillschema command
>
> http://msdn.microsoft.com/library/de...chematopic.asp
>
> I hope this helps,
>
> Cor
>



 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      26th Sep 2005
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.

"Wayne Wengert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Done with CommandBuilder tascienu@ecoaches.com Microsoft ADO .NET 5 12th Sep 2005 07:41 AM
CommandBuilder problem. Is it broken? vb.net2003. Jeremy Microsoft VB .NET 1 14th May 2005 11:21 PM
CommandBuilder Antonio Prieto Microsoft ADO .NET 5 23rd Nov 2004 10:09 AM
little problem replacing commandbuilder =?Utf-8?B?S2Vu?= Microsoft ADO .NET 1 15th Nov 2004 10:39 PM
CommandBuilder Problem Joao Santa Barbara Microsoft ADO .NET 2 26th Aug 2003 03:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:04 PM.