944,052 Members | Top Members by Rank

Ad:
Oct 13th, 2007
0

simultaneous MS Access Database access problem using VB6 program.

Expand Post »
I am using MS Access database by a vb6 program for multiuser environment.
In the program I have written code for autogenerating employee_id which is primary key in the table.
When entering records simultaneously from two or more workstation,
It gives a problem

Run time error
The changes you requested to the table were not successful because they would create duplicate values in the primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

How to resolve it.
Is there any way to restrict the database from accessing when record appending goes on by other workstation.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dilip_singh3 is offline Offline
24 posts
since Oct 2007
Oct 13th, 2007
0

Re: simultaneous MS Access Database access problem using VB6 program.

using the bold lines below in the code we can handle simultaneous access

Private Sub Command1_Click()
CNN.BeginTrans
If Not VALIDATE() Then Exit Sub
Call GENERATE_EMP_ID
CNN.Execute "INSERT INTO EM VALUES ('" + ID + "', '" + txt_code.Text + "', '" + txt_name.Text + "', " & Val(txt_basic.Text) & ")"
Call SET_DATA_TO_GRID
CNN.CommitTrans
MsgBox "EMPLOYEE ID IS : " + UCase(ID)
CLEAR_CONTROLS
End Sub
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dilip_singh3 is offline Offline
24 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Save code to text file?
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB codes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC