Solved

Primary Key Problem

Posted on 1998-08-26
4
179 Views
Last Modified: 2010-03-19
I am using Access97 Front end on SQL 6.5 backend.  I have 3 primary keys set on a table, one is an identity column. I am opening up the linked table in access and trying to copy and paste multiple records by using the record selectors. After Updating I get a #DELETED in every field. But after I reopen the table the records that I have just pasted reappear.  Shouldn't the identity column update as the records are pasted? If I do the same thing with an access table there is absolutely no problem, everything updates automatically.  Help!!
0
Comment
Question by:rvindust
  • 2
4 Comments
 
LVL 1

Expert Comment

by:DennisH
Comment Utility
This is kind of a sticky problem with Identity fields in SQL Server.  You are not allowed to set the value of the identity field.  Your best bet would be to open 2 recordsets, one on your Access table and one on your SQL Server table.  Iterate through the Access recordset and copy the fields (except the identity field) to the SQL Server recordset.

Another approach would be to create an Access query of your Access table that does NOT include the field that is the identity field in SQL Server.  Then create a query or view for the SQL Server table that does not include the identity field.  Then try copying and pasting records between the datasheet views of both queries.

0
 

Expert Comment

by:manish77
Comment Utility
Are you using bound control or are u using your own recordsets through code??
0
 

Author Comment

by:rvindust
Comment Utility
I am using bound controls to the form recordsource.  I don't quite understand your question. The form recordsource in some cases is an access query and other case I set it through using VB open recordset.
0
 

Accepted Solution

by:
manish77 earned 20 total points
Comment Utility
My advice to you is not to use the form record source through an access query but to manually populate and maintain it through VB code. SQL Server does not automatically propogate the identity value back to access on an insert. You have to make another query to get the value and then populate the feild.
hope this helps
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now