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()