In my program I have an EmployeeRegistry table which holds data of each employee's work attendance. Every attendance record is uniquely distinguished by an IDENTITY COLUMN called "AttendanceID" which has an IDENTITY SEED of 1 and an IDENTITY increment of 1. However when I try to insert an attendance record to the table via my VB.NET program. it gives an error saying:
"An explicit value for the identity column in table 'EmployeeRegistry' can only be specified when a column list is used and IDENTITY_INSERT is ON." I tried to insert data into the table using an SQL query via the SQL management studio and it inserted the data without a problem. What might be wrong?
Here's the coding:
Public Sub SaveRecord() Dim objSys As New SpringsSystem Dim objCommand As New SqlCommand() Dim objReader As SqlDataReader Try objSys.Connect() objCommand.Connection = objSys.objConnection objCommand.CommandText = "SELECT AttendanceID FROM EmployeeRegistry WHERE AttendanceID = '" & Me.AttendanceNumber & "'" objReader = objCommand.ExecuteReader()
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!