I'm a beginner of programming. I'm trying to make simple payroll system using vb.net 2003 and Access 2007. When I press 'delete' button in this application, having a "Specified cast is not valid" error.
conPayroll.Open()
Dim strSQL As String
strSQL = "select*from EMT where Empno='" & mskEmpno.ClipText & "'"
comEMT.CommandText = strSQL
drEMT = comEMT.ExecuteReader
If strStatus = "Add" Then
If drEMT.Read Then
MessageBox.Show("Record already exist-Enter another Employee no.", "Record existance check", MessageBoxButtons.OK, MessageBoxIcon.Information)
mskEmpno.defaultText = "_____"
mskEmpno.Focus()
Else
txtNa.Enabled = True
gbPersonal.Enabled = True
gbEmployeement.Enabled = True
txtNa.Focus()
End If
Else
If Not drEMT.Read Then
MessageBox.Show("Record doest not exist-Enter another employee no", "Record existance check", MessageBoxButtons.OK, MessageBoxIcon.Information)
mskEmpno.defaultText = "_____"
mskEmpno.Focus()
Else
txtNa.Enabled = True
gbPersonal.Enabled = True
gbEmployeement.Enabled = True
[b]Call display_Record()
If strStatus = "Edit" Then
mskEmpno.Focus()
Else
Dim Ans As DialogResult
Ans = MessageBox.Show("Do you want to delete this record?", "Conformation for deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
drEMT.Close()
Dim strSQL2 As String
strSQL2 = "delete from EMT where Empno='" & mskEmpno.ClipText & "'"
comEMT.ExecuteNonQuery()
MessageBox.Show("Record is delete from EMT sucvessfully", "Deleteing and existing record", MessageBoxButtons.OK, MessageBoxIcon.Information)[/b]
How can I solve this problem?
Thank you,

New Topic/Question
Reply



MultiQuote







|