Why done work is it some thing worng i only wan edit one or delete one of it?
Private Sub btnedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnedit.Click
If String.IsNullOrWhiteSpace(txtadmin.Text) Or String.IsNullOrWhiteSpace(txtname.Text) Or String.IsNullOrWhiteSpace(txtcourse.Text) Or String.IsNullOrWhiteSpace(txtic.Text) Or String.IsNullOrWhiteSpace(txtgender.Text) Or String.IsNullOrWhiteSpace(txtaddress.Text) Or String.IsNullOrWhiteSpace(DateTimePicker1.Value) Or String.IsNullOrWhiteSpace(txttel.Text) Or String.IsNullOrWhiteSpace(txtemail.Text) Or String.IsNullOrWhiteSpace(txttype.Text) Then
MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Try
Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb")
Dim sql As String = "UPDATE tbl_datain SET UserName='" & txtname.Text & "' AdminNo = '" & txtadmin.Text & "'Course Title = '" & txtcourse.Text & "'""'IC No = '" & txtic.Text & "'""'Gender = '" & txtgender.Text & "'""'Address= '" & txtaddress.Text & "'""'[Date of Birth] = '" & txtbirth.Text & "'Tel No = '" & txttel.Text & "'""'Email = '" & txtemail.Text & "''Personl = '" & txttype.Text & "'"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)
sqlCom.Connection = conn
conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
If sqlRead.Read() Then
MessageBox.Show("one eidt is Successfully'")
Else
MessageBox.Show("Have a great day..!!", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtname.Text = ""
txtadmin.Text = ""
txtcourse.Text = ""
txtic.Text = ""
txtgender.Text = ""
txtaddress.Text = ""
txtbirth.Text = ""
txttel.Text = ""
txtemail.Text = ""
txttype.Text = ""
txtadmin.Focus()
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub btnremove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnremove.Click
If String.IsNullOrWhiteSpace(txtadmin.Text) Or String.IsNullOrWhiteSpace(txtname.Text) Or String.IsNullOrWhiteSpace(txtcourse.Text) Or String.IsNullOrWhiteSpace(txtic.Text) Or String.IsNullOrWhiteSpace(txtgender.Text) Or String.IsNullOrWhiteSpace(txtaddress.Text) Or String.IsNullOrWhiteSpace(DateTimePicker1.Value) Or String.IsNullOrWhiteSpace(txttel.Text) Or String.IsNullOrWhiteSpace(txtemail.Text) Or String.IsNullOrWhiteSpace(txttype.Text) Then
MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Try
Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb")
Dim sql As String = "DELETE * FROM tbl_datain WHERE UserName='" & txtname.Text & "' AdminNo = '" & txtadmin.Text & "'Course Title = '" & txtcourse.Text & "'""'IC No = '" & txtic.Text & "'""'Gender = '" & txtgender.Text & "'""'Address= '" & txtaddress.Text & "'""'[Date of Birth] = '" & txtbirth.Text & "'Tel No = '" & txttel.Text & "'""'Email = '" & txtemail.Text & "''Personl = '" & txttype.Text & "'"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)
sqlCom.Connection = conn
conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
If sqlRead.Read() Then
MessageBox.Show("one info has delete")
Else
MessageBox.Show("Have a great day..!!", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtname.Text = ""
txtadmin.Text = ""
txtcourse.Text = ""
txtic.Text = ""
txtgender.Text = ""
txtaddress.Text = ""
txtbirth.Text = ""
txttel.Text = ""
txtemail.Text = ""
txttype.Text = ""
txtadmin.Focus()
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class