Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connStr As String
Dim conn As MySqlConnection
If Not conn Is Nothing Then conn.Close() ''pooling=false CharSet=gbk;
connStr = "server=" & TextBox1.Text & "; port=" & TextBox2.Text & "; user id=" & TextBox3.Text & "; password=" & TextBox4.Text & "; database=" & TextBox5.Text & "; "
Try
conn = New MySqlConnection(connStr)
conn.Open()
Dim sqlstr As String
Dim checkname As String
checkname = "admin1"
Dim rs As MySqlDataReader ''这里定义肯定是错了
sqlstr = "select * from users where User='" + checkname + "'"
TextBox8.Text = rs.GetByte(sqlstr) '这里也错了 求助想在textbox8显示出所要内容写法
conn.Close()
Catch ex As MySqlException
TextBox8.Text = "连接到服务器的错误:" + ex.Message
End Try
End Sub
Private Sub Button1_Click.....
Dim connStr As String
Dim conn as MySqlConnection
connStr = ...
Try
conn = New MySqlConnection(connStr)
Dim sqlstr As String
Dim checkname As String
conn.open()
checkname = "admin1"
Dim rs As MySqlDataReader
sqlstr = "select * from users WHERE name='" + checkname + "'"
Dim myCommand As New MySqlCommand(sqlstr, conn)
rs = myCommand.ExecuteReader()
While rs.Read()
TextBox8.Text = rs.GetString(1))
End While
rs.close()
conn.close()
Catch ex As MySqlException
TextBox8.Text = ex.Message
End Try
End Sub