I'm new in VBA Excel macro. I want to create a vba script to insert a record from Excel worksheet and I tried with a simple script for testing but I hit below error:
Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF
oConn.Execute "SET IDENTITY_INSERT [table1] ON" strSQL5 = "INSERT INTO [table1] ([ID],[Company],[EmployeeID],[Category]) VALUES (2956,'ABCDSG','ABCDSG1600338','Documentation')"
oConn.Execute strSQL5
oConn.Execute "SET IDENTITY_INSERT [table1] OFF"
The error message occurs even though I've put SET IDENTITY_INSERT [table1] ON.
Any idea what causing the error and how to fix it?
Thank you