01.
Dim
myAdapter
As
New
MySqlDataAdapter
02.
Dim
myCommand
As
New
MySqlCommand
03.
Dim
myData
As
MySqlDataReader
04.
Dim
add
As
String
05.
Dim
connect
As
MySqlConnection
06.
connect =
New
MySqlConnection()
07.
08.
connect.ConnectionString =
"Server=127.0.0.1 ;Userid=root ;Password=123456;Database=login "
09.
10.
11.
12.
Dim
usercheck
As
String
=
"SELECT username FROM logintest WHERE username = '"
+ txtuser.Text +
"'"
13.
Try
14.
connect.Open()
15.
Catch
myerror
As
MySqlException
16.
MsgBox(
"Error connecting to database. Check your internet connection."
, MsgBoxStyle.Critical)
17.
End
Try
18.
19.
20.
21.
myCommand.Connection = connect
22.
myCommand.CommandText = usercheck
23.
myAdapter.SelectCommand = myCommand
24.
myData = myCommand.ExecuteReader
25.
26.
27.
If
myData.HasRows = 0
Then
28.
add =
"INSERT INTO logintest (username,password) VALUES('"
+ txtuser.Text +
"','"
+ txtpass.Text +
"')"
29.
MsgBox(
"สมัครเรียบร้อย"
)
30.
Else
31.
MsgBox(txtuser.Text &
" is being register, try again."
, MsgBoxStyle.Information)
32.
End
If
33.
connect.Close()