954,224 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

simultaneous MS Access Database access problem using VB6 program.

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.

dilip_singh3
Newbie Poster
24 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

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

dilip_singh3
Newbie Poster
24 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You