0
我想在Vb.net中使用MySQL进行聊天,我想将聊天加载到列表框中,其中(用户名)'par''和(消息)。Vb.net Mysql在一个数据中的多个查询
但它不断显示我的错误,我不明白如何解决它。
这里是我的代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim stringConn As String
Dim stringCmd As String
Dim myConn As MySqlConnection
Dim myCmd As MySqlCommand
stringCmd = "SELECT par, message FROM chat"
stringConn = "server=localhost; user id=studio; password=mypw; database=studio;"
myConn = New MySqlConnection(stringConn)
myCmd = New MySqlCommand(stringCmd, myConn)
myConn.Open()
Dim myReader As MySqlDataReader
myReader = myCmd.ExecuteReader()
'Reset your List box here.
ListBox1.Items.Clear()
While myReader.Read()
--------------Here is my problem ---------------
ListBox1.Items.Add(myReader.GetString(1//username//) & " " & myReader.GetString(2//message//))
---- end--了---问题---
End While
myReader.Close()
myConn.Close()
End Sub
请张贴错误是什么如果你说只有错误将如何o他们明白。 –