出于某种原因,我的messageBox没有出现!有人可以帮助我:
代码:
item = InputBox("What is the item?", "InputBox Test", "Type the item here.")
If item = "shoe" Then
Dim connStr As String = ""
Dim connection As New MySqlConnection(connStr)
Dim READER As MySqlDataReader
connection.Open()
Dim Query As String
Query = "UPDATE table set item = noOfItems+1 where username= '" & Login.txtusername.Text & "'"
COMMAND = New MySqlCommand(Query, connection)
READER = COMMAND.ExecuteReader
If (READER.Read() = True) Then
Query = "select * from table where username= '" & Login.txtusername.Text & " '"
Dim noOfItems As Integer
Dim username As String
noOfItems = READER("noOfItems")
username = READER("username")
MessageBox.Show(username & "- The number of items you have is: " & noOfItems)
End If
Else
MsgBox("Unlucky, Incorrect item. Please see hints. Your score still remains the same")
提前致谢:)
答案 0 :(得分:0)
Dim item As Object
Dim Command As MySqlCommand
Dim READER As MySqlDataReader
Dim connection As MySqlConnection
Dim Query As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
item = InputBox("What is the item?", "InputBox Test", "Type the item here.")
If item = "shoe" Then
Dim connStr As String = ""
Dim connection As New MySqlConnection(connStr)
connection.Open()
Query = "select * from table where username= '" & txtusername.Text & " '"
READER = Command.ExecuteReader
If READER.HasRows Then
Dim noOfItems As Integer
Dim username As String
noOfItems = READER("noOfItems") + 1
username = READER("username")
Query = "UPDATE table set item = '" & noOfItems & "' where username= '" & txtusername.Text & "'"
Command = New MySqlCommand(Query, connection)
Command.ExecuteNonQuery()
MessageBox.Show(username & "- The number of items you have is: " & noOfItems)
End If
Else
MsgBox("Unlucky, Incorrect item. Please see hints. Your score still remains the same")
End If
connection.close()
Catch ex As Exception
MessageBox.Show("Error")
End Try
End Sub