2016-07-04 5 views
-1

이 항목에 대한 일부 스레드가 있지만 어떤 이유로 이러한 항목이 저에게 맞지 않습니다. 그래서 그것이 내 코드입니다.VB.Net - ExecuteReader : CommandText 속성이 초기화되지 않았습니다.

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

누구나 내 문제에 대한 아이디어가 있습니까? 으로 ErrorMessage 상태로

답변

0

, 당신의 CommandText은 빈 문자열 (strSQL2) 여기에 있습니다 :

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

당신은 빈 SQL 절을 실행할 수 없습니다.