data type mismatch in criteria expression
Dim connectionString As String = dbconstr
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "INSERT INTO [tblEmployees] " & _
"([datEmpFirstName]," & _
"[datEmpLastName]," & _
"[datEmpDOB]," & _
"[datEmpStartDate]," & _
"[datCompanyID]," & _
"[datEmpInitials]," & _
"[datEmpIDNumber]," & _
"[datLeaveID]," & _
"[datBenefitID]," & _
"[datDeductionID]," & _
"[datNOKID]," & _
"[datEmpNumberOfDependants]," & _
"[datEmpOccupation]," & _
"[datEmpCellNumber]," & _
"[datEmpPassportNumber]," & _
"[datEmpEmailAddress]," & _
"[datEmpPostalAddress]," & _
"[datEmpPostalCode]," & _
"[datEmpResidentialAddress]," & _
"[datEmpResidentialCode]," & _
"[datEmpPhoneNumber]," & _
"[datEmpEndDate]," & _
"[datEmpPayFrequency]," & _
"[datEmpPayMethod]," & _
"[datEmpPaySlipLanguage]," & _
"[datEmpBankName]," & _
"[datEmpBankAccountType]," & _
"[datEmpBankAccountNumber]," & _
"[datEmpBankBranchName]," & _
"[datEmpBankBranchCode]," & _
"[datStatus]," & _
"[datEmpRace]," & _
"[datEmpOccupationalLevel]," & _
"[datEmpOccupationalCategory]," & _
"[datEmpdisability]," & _
"[datEmpProvince]," & _
"[datEmpExperience]," & _
"[datEmpNationality]," & _
"[datEmpPayDay]," & _
"[datEmpSalary]" & _
") VALUES (" & _
"'" & txtEmpFirstName.Text & "'," & _
"'" & txtEmpLastName.Text & "'," & _
"'" & dtpEmpDOB.Text & "'," & _
"'" & dtpEmpStartDate.Text & "'," & _
"'" & cmbCompanyID.Text & "'," & _
"'" & txtEmpInitials.Text & "'," & _
"" & nudEmpIDNumber.Value & "," & _
"'" & cmbLeaveID.Text & "'," & _
"'" & cmbBenefitID.Text & "'," & _
"'" & cmbDeductionID.Text & "'," & _
"'" & cmbNOKID.Text & "'," & _
"" & nudEmpNumberOfDependants.Value & "," & _
"'" & cmbEmpOccupation.Text & "'," & _
"'" & txtEmpCellNumber.Text & "'," & _
"'" & txtEmpPassportNumber.Text & "'," & _
"'" & txtEmpEmailAddress.Text & "'," & _
"'" & txtEmpPostalAddress.Text & "'," & _
"'" & txtEmpPostalCode.Text & "'," & _
"'" & txtEmpResidentialAddress.Text & "'," & _
"'" & txtEmpResidentialCode.Text & "'," & _
"'" & txtEmpPhoneNumber.Text & "'," & _
"'" & dtpEmpEndDate.Text & "'," & _
"'" & cmbEmpPayFrequency.Text & "'," & _
"'" & cmbEmpPayMethod.Text & "'," & _
"'" & cmbEmpPaySlipLanguage.Text & "'," & _
"'" & cmbEmpBankName.Text & "'," & _
"'" & cmbEmpBankAccountType.Text & "'," & _
"'" & txtEmpBankAccountNumber.Text & "'," & _
"'" & txtEmpBankBranchName.Text & "'," & _
"'" & txtEmpBankBranchCode.Text & "'," & _
"'active'," & _
"'" & cmbEmpRace.Text & "'," & _
"'" & cmbEmpOccupationalLevel.Text & "'," & _
"'" & cmbEmpOccupationalCategory.Text & "'," & _
"'" & cmbEmpDisability.Text & "'," & _
"'" & txtEmpProvince.Text & "'," & _
"'" & txtEmpExperience.Text & "'," & _
"'" & cmbEmpNationality.Text & "'," & _
"'" & dtpEmpPayDay.Text & "'," & _
"" & nudEmpSalary.Value & "" & _
")"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim rowsAffected As Integer = 0
dbConnection.Open()
Try
rowsAffected = dbCommand.ExecuteNonQuery
MessageBox.Show(txtEmpLastName.Text & "," & txtEmpFirstName.Text & " has been added.", "The Adviser Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
'MessageBox.Show("A user already exist with such id number", "The Adviser Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
MsgBox(ex.Message)
nudEmpIDNumber.Value = 0
nudEmpIDNumber.Focus()
Finally
dbConnection.Close()
clrfrm()
End Try
|