Visual studio 2010 Visual Basic 2010无法连接PHPMYADMIN(脱机)
我在登录系统中遇到问题。 这是我的编码:我已经在表单中添加了引用MySQL.Data。当我单击按钮时,会显示此错误消息(mscorlib.dll中出现“System.Collections.Generic.KeyNotFoundException”类型的首次意外异常)Visual studio 2010 Visual Basic 2010无法连接PHPMYADMIN(脱机),visual-studio-2010,phpmyadmin,Visual Studio 2010,Phpmyadmin,我在登录系统中遇到问题。 这是我的编码:我已经在表单中添加了引用MySQL.Data。当我单击按钮时,会显示此错误消息(mscorlib.dll中出现“System.Collections.Generic.KeyNotFoundException”类型的首次意外异常) Imports MySql.Data.MySqlClient Public Class Form1 Public conn As MySqlConnection Private Sub Form1_Load(ByV
Imports MySql.Data.MySqlClient
Public Class Form1
Public conn As MySqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
conn = New MySqlConnection("server=localhost; user id=root; password=; database=test")
Try
conn.Open()
Dim sqlquery As String = "SELECT * FROM yy WHERE Username = '" & TextBox1.Text & "';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader
While data.Read()
If data.HasRows() = True Then
If data(2).ToString = TextBox2.Text Then
MsgBox("Login")
Else
MsgBox("Failed Login")
End If
Else
MsgBox("Failed Login")
End If
End While
Catch ex As Exception
End Try
End Sub
End Class
清除你的恶意空
捕获块并读取异常。你有SQL注入漏洞。不要以纯文本形式存储密码!谢谢你的信息!!