i want to save data entered into my form into the database but it is telling "column name or number of supplied values does not match table definition"
here is my code
help please
Private Sub BtnSave_Click(sender As Object, e As EventArgs) Handles BtnSave.Click
'Error checking:Personal information
Try
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = "Insert into Employee values('" & Cmbgender.Text & "','" & CmbTittle.Text & "','" & Txtname.Text & "','" & Txtsurname.Text & "','" & Dateofbirth.Text.ToString & "', '" & TxtPhysicalAddress1.Text & "', '" & TxtPhysicalAddress2.Text & "','" & Cmbcountry.Text & "','" & Txtprovince.Text & "','" & Txtcity.Text & "','" & CmbEmpType.Text & "','" & ComboBox1.Text & "','" & TxtEmail.Text & "','" & Txtphone.Text & "','" & Txtusername.Text & "','" & Txtpassword.Text & "','" & Hiredate.Text.ToString & "' )"
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
MsgBox("Succesfully Added", MsgBoxStyle.Information, "add")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
If Cmbgender.Text = "" Then
MessageBox.Show("Selection empty for Employee Gender", "Employee Gender", MessageBoxButtons.OK, MessageBoxIcon.Error)
Cmbgender.ResetText()
Cmbgender.Focus()
ElseIf CmbTittle.Text = "" Then
MessageBox.Show("Please Select a Tittle for Employee", "Tittle", MessageBoxButtons.OK, MessageBoxIcon.Error)
CmbTittle.ResetText()
CmbTittle.Focus()
ElseIf Txtname.Text = "" Then
MessageBox.Show("Name text fied is empty", "Name", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtname.Clear()
Txtname.Focus()
ElseIf IsNumeric(Txtname.Text) Then
MessageBox.Show("Please enter a valid Name" & vbLf & "A number was entered", "Name", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtname.Clear()
Txtname.Focus()
ElseIf (Txtname.TextLength < 2) Then
MessageBox.Show("Please enter a valid Name" & vbLf & "You entered a Single Letter", "Name", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtname.Clear()
Txtname.Focus()
ElseIf IsNumeric(Txtsurname.Text) Then
MessageBox.Show("Please enter a valid Surname" & vbLf & "A number was entered", "Surname", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtsurname.Clear()
Txtsurname.Focus()
ElseIf Txtsurname.Text = "" Then
MessageBox.Show("Surname text fied is empty", "Surname", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtsurname.Clear()
Txtsurname.Focus()
ElseIf (Txtsurname.TextLength < 2) Then
MessageBox.Show("Please enter a valid surame" & vbLf & "You entered a Single Letter", "Surname", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtsurname.Clear()
Txtsurname.Focus()
ElseIf Dateofbirth.Value > Date.Today Then
MessageBox.Show("Please Select a Date of birth which is Prior to the Current Date", "DOB", MessageBoxButtons.OK, MessageBoxIcon.Error)
Dateofbirth.ResetText()
Dateofbirth.Focus()
'Error checking:Address details
ElseIf TxtPhysicalAddress1.Text = "" Then
MessageBox.Show("Physical Address 1 text fied is empty", "Physical Address 1", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtPhysicalAddress1.Clear()
TxtPhysicalAddress1.Focus()
ElseIf TxtPhysicalAddress1.TextLength < 20 Then
MessageBox.Show("Add a valid Address Eg:Betrams 1234, Johannesburg", "Physical Address 1", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtPhysicalAddress1.Clear()
TxtPhysicalAddress1.Focus()
ElseIf TxtPhysicalAddress2.Text = "" Then
MessageBox.Show("Physical Address 2 text fied is empty", "Physical Address 2", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtPhysicalAddress2.Clear()
TxtPhysicalAddress2.Focus()
ElseIf TxtPhysicalAddress1.TextLength < 20 Then
MessageBox.Show("Add a valid Address Eg:Betrams 1534, Johannesburg", "Physical Address 2", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtPhysicalAddress2.Clear()
TxtPhysicalAddress2.Focus()
ElseIf Cmbcountry.Text = "" Then
MessageBox.Show("Selection empty for Country", "Employee Country", MessageBoxButtons.OK, MessageBoxIcon.Error)
Cmbcountry.ResetText()
Cmbcountry.Focus()
ElseIf Txtprovince.Text = "" Then
MessageBox.Show("Province text fied is empty", "Province", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtprovince.Clear()
Txtprovince.Focus()
ElseIf IsNumeric(Txtprovince.Text) Then
MessageBox.Show("Please enter a Province" & vbLf & "A number was entered" & vbLf & "Eg: Pretoria", "Province", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtprovince.Clear()
Txtprovince.Focus()
ElseIf (Txtprovince.TextLength < 4) Then
MessageBox.Show("Please enter a valid Province" & vbLf & "You entered Letters which is not a province" & vbLf & "Eg: Pretoria", "Province", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtprovince.Clear()
Txtprovince.Focus()
ElseIf Txtcity.Text = "" Then
MessageBox.Show("City text fied is empty", "City", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtcity.Clear()
Txtcity.Focus()
ElseIf IsNumeric(Txtcity.Text) Then
MessageBox.Show("Please enter a valid city" & vbLf & "A number was entered" & vbLf & "Eg: Montana", "City", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtcity.Clear()
Txtcity.Focus()
ElseIf (Txtcity.TextLength < 4) Then
MessageBox.Show("Please enter a valid city " & vbLf & "You entered Letters which is not a city" & vbLf & "Eg: Montana", "City", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtcity.Clear()
Txtcity.Focus()
'Error Checking: Administrative Information
ElseIf CmbEmpType.Text = "" Then
MessageBox.Show("Please select Employee Type", "Employee Type", MessageBoxButtons.OK, MessageBoxIcon.Error)
CmbEmpType.ResetText()
CmbEmpType.Focus()
ElseIf CmbTittle.Text = "" Then
MessageBox.Show("Please select Employee Tittle", "Employee Tittle", MessageBoxButtons.OK, MessageBoxIcon.Error)
CmbTittle.ResetText()
CmbTittle.Focus()
ElseIf TxtEmail.Text = "" Then
MessageBox.Show("Email Address text fied is empty", "Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtEmail.Clear()
TxtEmail.Focus()
ElseIf TxtEmail.TextLength < 17 Then
MessageBox.Show("Add a valid Email Address eg:Example@gmail.com", "Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtEmail.Clear()
TxtEmail.Focus()
ElseIf Txtphone.Text = "" Then
MessageBox.Show("Phone Number text field is empty" & vbLf & "Or Check The Data Type", "Adding Phone Number", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtphone.Clear()
Txtphone.Focus()
ElseIf Txtphone.TextLength < 10 Then
MessageBox.Show("Wrong Input, Add a complete Phone Number", "Adding Phone Number", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtphone.Clear()
Txtphone.Focus()
ElseIf IsNumeric(Txtusername.Text) Or Txtusername.Text = "" Then
MessageBox.Show("Username text field is empty", "Username", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtusername.Clear()
Txtusername.Focus()
ElseIf IsNumeric(Txtpassword.Text) Or Txtpassword.Text = "" Then
MessageBox.Show("Password text field is empty", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error)
Txtpassword.Clear()
Txtpassword.Focus()
ElseIf Hiredate.Value > Date.Today Then
MessageBox.Show("Please Select a Hire Date which is Prior to the Current Date", "DOB", MessageBoxButtons.OK, MessageBoxIcon.Error)
Hiredate.ResetText()
Hiredate.Focus()
End If
End Sub
End Class