• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 844
  • Last Modified:

ODBC DataAdapter error when automaticaly generating UPDATE and DELETE command for Access database

Why can't ODBC data adapter automaticaly generate UPDATE and DELETE commands for Access database? The error message (warning) is "Could not determine which columns uniquely identify the rows for "MyTable".".

I defined the primary key column in my Access database like this:

Primary Key: Yes
Data Type: AutoNumber
New Values: Increment
Format: (blank)
Caption: (blank)
Indexed: Yes (No Duplicates)

How can I define these commands myself? Could anyone clarify to me the usage of parameters with commands?
0
Milos
Asked:
Milos
  • 3
  • 3
  • 2
  • +2
1 Solution
 
DaniProCommented:
I think the it's a bug of the ODBC driver ... try to use the OLE DB connection.
(In the Provider OLE DB list you must select the Microsoft Jet 4.0 OLE DB Provider)
0
 
MilosAuthor Commented:
That helped. It works.

I'll ask you one more question before I accept (which I will) your answer and I'll give you 300 points if you help me again. I hope it's not hard.

I have two forms, main and, for example, options form. I need to open options form from main form and use a value from main form in the options form. How do I send/get some value from one form to another?
0
 
DaniProCommented:
There's more solutions ...  here one:

Option wOption = new Option();
if (wOption.ShowDialog() == DialogResult.OK)
{
      string      value = wOption.paramValue;
}


i.e.: paramValue must have public or internal modifiers
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MilosAuthor Commented:
I didn't understand a word now. What is Option? Why dialog? (sorry for my lack of knowledge)

Here's what I do:

private void menuItem_Click(object sender, System.EventArgs e)
{
      new Opcije().Show();
}

This is a procedure in Main form. "Opcije" iz a Windows Form. How can I send a value to Opcije, or even better, how can I change the property of, for example, text box in form Opcije in this procedure.
0
 
DaniProCommented:
Option is the name of your form ...

If you want pass a parameter to the window you must create a constructor in your form that access parameter and pass it:

// ..in MainForm
string      parmValue = "hello";
Opcije wOption = new Opcije(parmValue);
if (wOption.ShowDialog() == DialogResult.OK)
{
// here i get the return value
     string     value = wOption.paramValue;
}

// ..in parm Form
public Opcije(string myParm)
{
      InitializeComponent();

      // ... use myParm
}

I use ShowDialog for open the form in dialog mode that is better for a param window but you can also use .Show().
0
 
MilosAuthor Commented:
Thank you.
0
 
KBannerCommented:
Can I ask. A very quick question over this.

Using Ole Db dataAdapter, can I set it up to a table without a primary key. Have been stuck for ages on this. I'd be most grateful for a guiding anwser!! I cannot use a primary key in the software design.

Thanks in advance
Stuart
0
 
gmanglerCommented:
I have been trying for several hours with this same problem.

The answer says

'I think the it's a bug of the ODBC driver ... try to use the OLE DB connection.
(In the Provider OLE DB list you must select the Microsoft Jet 4.0 OLE DB Provider) '

However I see no Jet OLE DB provider. How do I install it

The driver I have is 4.00.6205.00 - ODBCJT32.DLL  - 3/25/2003
and it is for Access. Not Jet

I cannot get it to write UPDATE or DELETE statements for me.
0
 
KBannerCommented:
Hi gmangler,

Am having the same problem with creating UPDATE and DELETE using any DataAdapter whether ODBC or OLE DB. It's because I don't have a primary key in my underlying table.
I think you have a primary key don't you??

As for Ole Db. Have you tried to create a Ole Db DataAdapter and Connection.

Might me teaching Grandy to suck eggs, but here goes.

Ole Db should be installed with vb.net

1.Try making a Ole Db Connection.
2. In View, click Toolbox, and then click the Data Tab.
3. You should see Ole DB Connection in there along with various other Connections and Adapters.
4. Drag onto form
5. Click connection String property for the Ole Db connection control, and chose New Connection
6. Should open up a dialog form. Click the 'Provider' Tab and in their should see 'Microsoft Jet 4.0 OLE DB Provider'
7. You can then set up your OleDb DataAdapter using this connection.

Can you do us a favour, can you just confirm that your error is due an error in ODBC DataAdapter rather than not having a primary key set in your underlying Table???

Stuart
0
 
gsilveyCommented:
I had the same problem (wizard could not create UPDATE or DELETE) and switched from ODBC connection to OLEDB Connection. The wizard now works.

However, now I am having problems with the VB.NET program that uses the db. I have checkboxes on my form that used to be automatically updated as I scrolled through a combo box. I've checked the properties of the checkboxes (Data Bindings / Checked) and they look fine to me. Do I need to do something different now that it is ole instead of odbc?

Thanks,
    Garry
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now