Imports MySql.Data.MySqlClient
Imports System.Data.SqlClient
Imports System.IO
Imports System.Threading
Public Class Form1
Dim MySqlConnection As MySqlConnection
Public Sub DeleteDirContents(ByVal dir As IO.DirectoryInfo)
Dim fa() As IO.FileInfo
Dim f As IO.FileInfo
fa = dir.GetFiles
For Each f In fa
f.Delete()
Next
Dim da() As IO.DirectoryInfo
Dim dl As IO.DirectoryInfo
da = dir.GetDirectories
For Each dl In da
DeleteDirContents(dl)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MySqlConnection As MySqlConnection
MySqlConnection = New MySqlConnection
MySqlConnection.ConnectionString = "server=localhost; user id=root; password=root; database=web " 'บรรทัดปัญหา
Try
MySqlConnection.Open()
Catch
MsgBox("ไม่สามารถเชื่อมต่อเซิฟเวอร์")
End Try
Dim MyAdapter As New MySqlDataAdapter
Dim sqlquary = "SELECT * From user WHERE id='" & TextBox1.Text & "'AND pass='" & TextBox2.Text & "'" 'บรรทัดปัญหา
Dim command As New MySqlCommand
command.Connection = MySqlConnection
command.CommandText = sqlquary
MyAdapter.SelectCommand = command
Dim Mydata As MySqlDataReader
Mydata = command.ExecuteReader()
If Mydata.HasRows = 0 Then
MsgBox("รหัสผิด")
Else
MsgBox("ล็อคอินสำเร็จ")
Me.Hide()
Form2.Show()
End If
End Sub