Public Class Register
Private Sub RegisterButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegisterButton1.Click
If Me.TextBoxUser.Text = "" Then
MessageBox.Show("โปรดกรอกรหัสผ่านด้วยครับ")
Me.textboxuser.Focus()
Exit Sub
End If
If Me.textboxEmail.Text = "" Then
MessageBox.Show("โปรดกรอกอีเมลด้วยครับ")
Me.textboxEmail.Focus()
Exit Sub
End If
If Me.TextBoxPass.Text = "" Then
MessageBox.Show("โปรดกรอกพาสเวิดด้วยครับ)")
Me.TextBoxPass.Focus()
Exit Sub
End If
Dim MyConnection As SqlClient.SqlConnection
'myConnection = New SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\Database1.sdf;"))
MyConnection = New SqlClient.SqlConnection("Server=db4free.net;User Id=kokaew1; Password=77172544; Database=testvb123; Pooling=false")
myConnection.Open()
Dim myCommand As SqlClient.SqlCommand = MyConnection.CreateCommand()
myCommand.CommandText = "INSERT INTO [mytable] ([Username], [email], [password]) VALUES " & _
" ('" & Me.TextBoxUser.Text & "','" & Me.TextBoxPass.Text & "'" & Me.TextBoxEmail.Text & "' ) "
myCommand.CommandType = CommandType.Text
myCommand.ExecuteNonQuery()
myConnection.Close()
MessageBox.Show("Save Successfully.")
Me.Hide()
Dim f As New frmLogin
f.Show()
End Sub
End Class
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL As String
strConnString = "Server=localhost;User Id=root; Password=root; Database=database; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open()