Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim constring As New MySqlConnection("SERVER=localhost;DATABASE=db_test;;User Id=root;Password=1234;")
Dim conn As New MySqlCommand("", constring)
constring.Open()
Dim id As String = TextBox1.Text
Dim name As String = TextBox2.Text
Dim tel As String = TextBox3.Text
If (TextBox1.Text.Trim() = "") OrElse (TextBox2.Text.Trim() = "") OrElse (TextBox3.Text.Trim() = "") Then
MessageBox.Show("กรุณากรอกข้อมูลให้ครบ", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
TextBox1.Focus()
End If
conn.CommandText = "insert into user (id,name.tel)values('" & id & "','" & name & "','" & tel & "')"
conn.ExecuteNonQuery()
constring.Close()
MsgBox("เพิ่มข้อมูล เรียบร้อยแล้ว ")