By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,238 Members | 1,485 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,238 IT Pros & Developers. It's quick & easy.

daAdapter.update without primary key

P: n/a
I got a table which without primary key.
case 1) I can process insertcommand and daMytable.update..etc
case 2) However, if i process updatecommand , As I run daMytable.update .It
returns error said..."cannot process update command without .... key"

I understand I didn't set primary key (is my fault).But why case 1) can
process very well ???
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Agnes,
When you are inserting a record into the database, you are doing just that
adding a record to the database. It really doesn't matter what its key is as
you are adding a record to the database.

However when you are updating or deleting a record in the database, how are
you going to know what record to update or delete? The normal method is to
use the database key.

I have not tried it, you should be able to create an update or delete
statement that considers every field on the record as the key, however if
your records are not distinct, then you will be updating or deleting more
then just that single record. This method would assume you are creating the
UpdateCommand or DeleteCommand via code without using CommandBuilder...

Hope this helps
Jay

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:eo**************@TK2MSFTNGP10.phx.gbl...
I got a table which without primary key.
case 1) I can process insertcommand and daMytable.update..etc
case 2) However, if i process updatecommand , As I run daMytable.update ..It returns error said..."cannot process update command without .... key"

I understand I didn't set primary key (is my fault).But why case 1) can
process very well ???

Nov 20 '05 #2

P: n/a
Comments inline

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:eo**************@TK2MSFTNGP10.phx.gbl...
I got a table which without primary key.
--That's the first problem. Although technically there's not a physical
requirement that every table have a key - tables without keys are the
hallmark of every poorly designed system, every bit as much as tables with
100+ fields are. If you simply put a key on your table, this whole problem
will go away and you'll incur no penalty. On the other hand, if you don't,
you're going to ahve to jump through hoops to get things to work as you want
and you'll close to door to manhy powerful features in all likelihood.
case 1) I can process insertcommand and daMytable.update..etc Without a PK field, it's going to be difficult and you'll have limited, very
limited desinger support.
case 2) However, if i process updatecommand , As I run daMytable.update ..It returns error said..."cannot process update command without .... key"
Right. By and large, although it's not perfect, when the IDE tells you
something is wrong, it's worth looking into. If you don't have a key then
you wont be able to use any of the code generating tools like the Wizards or
the CommandBuilder, to generate crud logic.

at this point, stick to the rule "The Key, the Whole Key and nothing about
the Key" and "It's ALL about the Key" and you'll be fine.
I understand I didn't set primary key (is my fault).But why case 1) can
process very well ???

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.