473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

primary key problem

hi,

when i add a row in a table of a dataset (using dt.rows.add), i expect the
primary key value to be gernarated automatically as i have set it to
Autonumber in access. But instead of generating autonumber, it does not do
anything, which results in null value in the primary key col of new row.

Although remedy to the above is, not to include the primary key in the
selectCommand so that Access does it itself. But i need to include the
primary key in the table because i have to set parent - child relationalship
with another table.

Could someone advise please how can the primarykey of a table in a dataset
to be populated by a unique identifier and not by a null value.

TIA
Irfan

Nov 21 '05 #1
6 1303
Irfan,

Is that table in an existing database or is it a new database?

Cor
Nov 21 '05 #2
Cor,

It is an existing database in MS Access, the tables are already created in
the actual database and now i have transferred them to into dataset.

irfan

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Irfan,

Is that table in an existing database or is it a new database?

Cor

Nov 21 '05 #3
On Tue, 21 Jun 2005 17:22:39 +0100, "Irfan" <ir***@asc-ltd.co.uk> wrote:

¤ hi,
¤
¤ when i add a row in a table of a dataset (using dt.rows.add), i expect the
¤ primary key value to be gernarated automatically as i have set it to
¤ Autonumber in access. But instead of generating autonumber, it does not do
¤ anything, which results in null value in the primary key col of new row.
¤
¤ Although remedy to the above is, not to include the primary key in the
¤ selectCommand so that Access does it itself. But i need to include the
¤ primary key in the table because i have to set parent - child relationalship
¤ with another table.
¤
¤ Could someone advise please how can the primarykey of a table in a dataset
¤ to be populated by a unique identifier and not by a null value.

See the following:

HOW TO: Retrieve the Identity Value While Inserting Records into Access Database By Using Visual
Basic .NET
http://support.microsoft.com/kb/815629/EN-US/
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #4

This is what i am doing to add a new row,

Dim dr As DataRow = dtComboBoxdata.NewRow
'set all columns
dr("ElementName") = EleName
dr("lineloadIDfk") = lineID
dr("fileIDfk") = fileID
dtComboBoxdata.Rows.Add(dr)
da.Update(ds, "comboBoxdata")

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Irfan,

Is that table in an existing database or is it a new database?

Cor

Nov 21 '05 #5
Irfan,

I am not sure anymore of the missingscheme method helps this, you can try
it.

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

My idea was not and than you have to add the autoincrement properties.
http://msdn.microsoft.com/library/de...mberstopic.asp

If you have this in a parentchildrelation this is AFAIK a hell of a job,
because the identifiere in the dataset is not the original one, however a
substitute. The original one is given at the insert time (and than you can
find the value of the indentifier as is described at @@Identity in Pauls
link). I would in this case first create the identifier and than add the
childs.

HoweverI prefer to use a Guid as the uniqueidentifier.

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

Probably do you have a now a long road to go.

I hope this helps something.

Cor


Nov 21 '05 #6
thanks, Cor, seems there is not a short cut.

I will go through the links, thanks again
irfan
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP12.phx.gbl...
Irfan,

I am not sure anymore of the missingscheme method helps this, you can try
it.

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

My idea was not and than you have to add the autoincrement properties.
http://msdn.microsoft.com/library/de...mberstopic.asp

If you have this in a parentchildrelation this is AFAIK a hell of a job,
because the identifiere in the dataset is not the original one, however a
substitute. The original one is given at the insert time (and than you can
find the value of the indentifier as is described at @@Identity in Pauls
link). I would in this case first create the identifier and than add the
childs.

HoweverI prefer to use a Guid as the uniqueidentifier.

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

Probably do you have a now a long road to go.

I hope this helps something.

Cor

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ghulam Farid | last post by:
Hi i have a table with primary key defined on col1 and col2. now i want to have col3 also included in primary key. when i alter the table it gives me error for duplicate rows. there is an option...
1
by: dev | last post by:
Hej There. We have a big problem. We have now for 4th years had a SQL Server without problems. But sutnely some of the primary keys are deleted. The subdata to the primary keys are not deleted....
9
by: 101 | last post by:
Taking a course on SQL. They are saying you can get better performance by having multiple files for a group. They then graphically show an example of "Primary" with multiple data files. I have...
7
by: Ilan Sebba | last post by:
I am trying to add a record using SQL. My problem is that the primary keys are foreign keys, and these foreign keys are autonumbers. I therefore do not know the primary keys of the record I am...
7
by: Philip | last post by:
Hey all, (Access 2000) I've been having a horror story with this design problem. My Database is Structured like This: AUTHORS, BOOKS, PAGES. Those are the Tables and each Item in each table...
2
by: stranger | last post by:
My database is set up so people can input parts orders. Sometimes they order the same parts on a monthly basis. I want to be able to duplicate past parts orders and have it pasted in with a new...
1
by: | last post by:
Hi, I am getting the following error when I run my Visual Basic application: "Cannot add primary key constraint since primary key is already set for the table" I am using datasets with...
3
by: Hugh O | last post by:
Hi, I am not sure if this type of question should be raised in this Newsgroup. If not please direct me. I am new to using RDO.Net data access but I thought I understood it. The 6 lines of...
8
by: shumaker | last post by:
I'm wondering if adding an autonumber primary key will improve the performance of a multiuser access database on a network share. I have a website that lists many tips for improving performance of...
9
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.