OleDbCommandBuilder question 
Author Message
 OleDbCommandBuilder question

Hi all.

In a Windows Application I have a DataGrid binded to a DataTable.

The data origin is an Access 2000 database. I want to use an
OleDbCommandBuilder object to generate automatically the INSERT, UPDATE,
DELETE commands to keep the data origin aligned with the DataTable.

When the Update(myDataTable) method is executed on the OleDbDataAdapter
object I receive the error:

"Dynamic generation of SQL statement for UpdateCommand not supported for a
SelectCommand that doesn't provide information about key column"
(... sorry for this translation from italian !)

The table of the Access database has an index which is NOT PrimaryKey: I
tried to change it into PrimaryKey and then the Update(..) method works
quite well.

Unfortunately I'm not allowed to modify the structure of the database my
customer is working with.
Is there some alternative way to specify information about key column?

Thanks in advance for any help.

Mario Simeone



Sat, 29 Jan 2005 23:20:28 GMT  
 OleDbCommandBuilder question
Hi Mario,

It is recommended to have primary key. The Command Builder will use this
information to automatically generate the UpdateCommand, DeleteCommand.

If you do not have primary key, you can set the command by yourself and
tell the DataAdapter how to access the database.
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconupdatingdat...
thdataadapterdataset.asp

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

Regards,

Bill Cheng
Microsoft Support Engineer
--------------------

| Newsgroups: microsoft.public.dotnet.languages.vb
| Subject: OleDbCommandBuilder question
| Lines: 29
| Organization: elettroSOFT
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

| Date: Tue, 13 Aug 2002 15:20:28 GMT
| NNTP-Posting-Host: 62.211.22.199

| X-Trace: news1.tin.it 1029252028 62.211.22.199 (Tue, 13 Aug 2002 17:20:28
MET DST)
| NNTP-Posting-Date: Tue, 13 Aug 2002 17:20:28 MET DST
| Path:
cpmsftngxa06!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!fr.usenet-ed
u.net!usenet-edu.net!news.telebyte.nl!newsfeeder.edisontel.com!news-out.tin.
it!news-in.tin.it!news1.tin.it.POSTED!not-for-mail
| Xref: cpmsftngxa06 microsoft.public.dotnet.languages.vb:59308
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Hi all.
|
| In a Windows Application I have a DataGrid binded to a DataTable.
|
| The data origin is an Access 2000 database. I want to use an
| OleDbCommandBuilder object to generate automatically the INSERT, UPDATE,
| DELETE commands to keep the data origin aligned with the DataTable.
|
| When the Update(myDataTable) method is executed on the OleDbDataAdapter
| object I receive the error:
|
| "Dynamic generation of SQL statement for UpdateCommand not supported for a
| SelectCommand that doesn't provide information about key column"
| (... sorry for this translation from italian !)
|
| The table of the Access database has an index which is NOT PrimaryKey: I
| tried to change it into PrimaryKey and then the Update(..) method works
| quite well.
|
| Unfortunately I'm not allowed to modify the structure of the database my
| customer is working with.
| Is there some alternative way to specify information about key column?
|
| Thanks in advance for any help.
|
| Mario Simeone
|
|
|
|



Mon, 31 Jan 2005 09:13:31 GMT  
 OleDbCommandBuilder question



Quote:
> Hi Mario,

> It is recommended to have primary key. The Command Builder will use this
> information to automatically generate the UpdateCommand,

DeleteCommand......

Thanks Bill.

I worked around the problem in this way:

I made a copy of the Database;
I created a PrimaryKey in the table I work with;
In a new project I used the Wizard to generate te Update, Delete, Insert
commands;
I pasted the definition of the commands in my original code (so without
using OleDbCommandBuilder).

Now it looks like working fine also with the original database, that is the
database without PrimaryKey.

Bye, Mario



Tue, 01 Feb 2005 15:20:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. questions,questions,questions.

2. Atten: Larry Serflaten - Re: Dictionary Questions, Questions, Questions

3. Questions!Questions!Questions

4. Questions Questions Questions

5. HELP QUESTION HELP QUESTION HELP QUESTION

6. 2 questions: Code doesn't work when I split database and Seek/Index question

7. FAQ = Frequently Asked Questions - vba - Please read before posting questions - unofficial - March posting

8. FAQ: Frequently Asked Questions - vba - please read before posting questions - unofficial February posting

9. FAQ - Frequently Asked Questions - vba - Please read before posting questions - unofficial - Jan 2003 posting

10. FAQ - frequently asked VBA questions - please read before posting questions - September posting - unofficial

11. FAQ - Frequently Asked Questions (vba) - please read before posting questions - August posting - unofficial

12. FAQ - Frequently Asked Questions - unoffical July posting - please read before posting questions - vba

 

 
Powered by phpBB® Forum Software