-1

我知道有一些关于这个话题的话题,但由于某种原因,这些东西都没有对我有用。这就是我的代码:

Dim strAccSQL As String = "SELECT nUserNo FROM dbo.tUser WHERE sUserID='" & AccountID.Text & "';"
        Dim catCMDAcc As SqlCommand = New SqlCommand(strAccSQL, AccCon)
        Dim myAccountReader As SqlDataReader = catCMDAcc.ExecuteReader()
        While myAccountReader.Read
            AccountNo.Text = myAccountReader(0)
        End While
        myAccountReader.Close()
        Con.Close()
        Con.Open()
        Dim strSQL2 As String
        Dim catCMD As SqlCommand = New SqlCommand(strSQL2, Con)
        Dim myReader As SqlDataReader = catCMD.ExecuteReader()
        InfoTextBox.Text &= Environment.NewLine & Now & " Account: " & AccountID.Text & " Found"
        CharacterName.Properties.Items.Clear()
        While myReader.Read()
            CharacterName.Properties.Items.Add(myReader(0))
        End While
        myReader.Close()
        AccCon.Close()
        Con.Close()

有人对我的问题有想法吗?

4

1 回答 1

0

正如错误消息所述,您的 CommandText 在这里是空字符串(strSQL2):

   Dim strSQL2 As String
   Dim catCMD As SqlCommand = New SqlCommand(strSQL2, Con)
   Dim myReader As SqlDataReader = catCMD.ExecuteReader()

您不能执行空的 sql 子句。

于 2016-07-04T07:54:43.057 回答