Guest User

Untitled

a guest
Jun 21st, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2. If TextBox1.Text & TextBox2.Text & TextBox3.Text & TextBox4.Text & TextBox5.Text & TextBox6.Text & TextBox7.Text = Nothing Then
  3. MsgBox("Please fill up all information.")
  4. TextBox1.Clear()
  5. TextBox2.Clear()
  6. TextBox3.Clear()
  7. TextBox4.Clear()
  8. TextBox5.Clear()
  9. TextBox6.Clear()
  10. TextBox7.Clear()
  11. Else
  12. Try
  13. Dim myConnection As OleDbConnection
  14. myConnection = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=G:Sem7 (Final Project)Bookstore POS Systempossys.mdb;Persist Security Info=false;")
  15. Dim myCommand As OleDbCommand
  16. myCommand = New OleDbCommand("INSERT INTO customer([ID],[c_name],[email],[phone],[nric],[sex],[race]) VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "'','" & TextBox3.Text & "'','" & TextBox4.Text & "'','" & TextBox5.Text & "'','" & TextBox6.Text & "'','" & TextBox7.Text & "')", myConnection)
  17. Dim id As New OleDbParameter("@ID", OleDbType.VarChar)
  18. Dim name As New OleDbParameter("@c_name", OleDbType.VarChar)
  19. Dim email As New OleDbParameter("@email", OleDbType.VarChar)
  20. Dim phone As New OleDbParameter("@phone", OleDbType.VarChar)
  21. Dim nric As New OleDbParameter("@nric", OleDbType.VarChar)
  22. Dim sex As New OleDbParameter("@sex", OleDbType.VarChar)
  23. Dim race As New OleDbParameter("@race", OleDbType.VarChar)
  24. id.Value = TextBox1.Text
  25. name.Value = TextBox2.Text
  26. email.Value = TextBox3.Text
  27. phone.Value = TextBox4.Text
  28. nric.Value = TextBox5.Text
  29. sex.Value = TextBox6.Text
  30. race.Value = TextBox7.Text
  31. myCommand.Parameters.Add(id)
  32. myCommand.Parameters.Add(name)
  33. myCommand.Parameters.Add(email)
  34. myCommand.Parameters.Add(phone)
  35. myCommand.Parameters.Add(nric)
  36. myCommand.Parameters.Add(sex)
  37. myCommand.Parameters.Add(race)
  38. myCommand.Connection.Open()
  39. myCommand.ExecuteNonQuery()
  40. myCommand.Dispose()
  41. MsgBox("Account Created", MsgBoxStyle.Information, "Registered!")
  42. myConnection.Close()
  43. Catch ex As Exception
  44. MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  45. End Try
  46. End If
  47. End Sub
Add Comment
Please, Sign In to add comment