-1

I know there are some threads about this topic, but for some reason nothing of these things given there didn't work for me. So that is my code:

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()

Anyone got an idea for my problem?

Flainity
  • 3
  • 1
  • 5

1 Answers1

0

As the errormessage states, your CommandText is empty string here (strSQL2):

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

You cannot execute an empty sql-clause.

Esko
  • 4,109
  • 2
  • 22
  • 37