Imports MySql.Data.MySqlClient
Imports System.Data
Public Class frmadd
Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
If MessageBox.Show("คุณต้องการออกจากระบบใช่หรือไม่ ?", "ยืนยันการออกจากระบบ", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Application.Exit()
End If
End Sub
Private Sub Btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnadd.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL As String
strConnString = "Server=localhost;User Id=root; Password=123456; Database=db_connectvb; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open()
strSQL = "insert into student(std_id,username,password,std_name,std_address,std_tel,std_sex) values("",txtusername.tex,txtpassword.tex,txtname.tex,txtaddress.txt,txttel.txt,"")"
objCmd = New System.Data.SqlClient.SqlCommand(strSQL, strConnString)
objCmd.ExecuteNonQuery()
objCmd.Parameters.Clear()
MessageBox.Show("บันทึกข้อมูลแล้ว")
' DbConn.Close()
End Sub
End Class