Hi every 1 i am trying to register an employee but for some reason my record is inserted twice. if i enter all details of employee and when i click save..after that if i chk my employee list i could see same record entered twice.here is my code.
Private Sub btnSaveEmp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveEmp.Click
Dim Con As New SqlConnection("Data Source=SAAD-PC\SQLEXPRESS;Initial Catalog=photoshoot;Integrated Security=True")
Dim cmd As New SqlCommand
Con.Open()
cmd.Connection = Con
cmd.CommandText = "INSERT INTO staff(FirstName,LastName,Address,Post_Code,Telephone,Email,UserName,Password,Confirm_Password,UserType) VALUES(@FirstName,@LastName,@Address,@Post_Code,@Telephone,@Email,@UserName,@Password,@Confirm_Password,@UserType)"
cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = txtEmpFirstName.Text
cmd.Parameters.Add("@LastName", SqlDbType.VarChar).Value = txtEmpLastName.Text
cmd.Parameters.Add("@Address", SqlDbType.VarChar).Value = txtEmpAddress.Text
cmd.Parameters.Add("@Post_Code", SqlDbType.VarChar).Value = txtEmpPostCode.Text
cmd.Parameters.Add("@Telephone", SqlDbType.Int).Value = txtEmpTelephone.Text
cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = txtEmpEmail.Text
cmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = txtEmpUsername.Text
cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = txtPassword.Text
cmd.Parameters.Add("@Confirm_Password", SqlDbType.VarChar).Value = txtEmpConfPass.Text
cmd.Parameters.Add("@UserType", SqlDbType.VarChar).Value = cmbEmpUserTypeReg.Text
If txtPassword.Text = txtEmpConfPass.Text Then
MsgBox("Record Successfully Saved")
Else
MsgBox("Both Password Fields Must Match Please Enter Password Again", MsgBoxStyle.Critical)
End If
cmd.ExecuteNonQuery()
Con.Close()
End Sub