나쁜 영어로는 유감입니다. 누군가가 오류 The conversion from type MySqlDataReader to type Integer is invalid
의 의미를 설명 할 수 있기를 바랍니다.변환 유형 정수 오해
나는 단순한 '어둡게 정수'라고 확신했지만 그보다 더 크거나 어리 석다.
내 btnLogin_Click 코드 :
Dim SQL As New MySQLHook
Dim loginResult As Integer
Dim User As TextBox = Me.Controls.Item("TextGebruikersNaam")
Dim Pass As TextBox = Me.Controls.Item("TextGebruikersPass")
If String.IsNullOrEmpty(User.Text) Or String.IsNullOrEmpty(Pass.Text) Then
MsgBox("Voer een gebruikersnaam en wachtwoord in om verder te gaan.", MsgBoxStyle.Exclamation, "Foutmelding")
User.Focus()
Else
loginResult = SQL.Results("SELECT * FROM tblgebruikers " & "WHERE GebruikersNaam='" & User.Text & "' AND " & "GebruikersPass='" & Pass.Text & "'")
If loginResult = 1 Then
' Login was good, todo: add code here
Else
MsgBox("De gebruikersnaam of wachtwoord is onjuist. Probeer het opnieuw of vraag een nieuw wachtwoord aan.", MsgBoxStyle.Exclamation, "Foutmelding")
User.Text = ""
Pass.Text = ""
User.Focus()
End If
End If
내 결과 코드 (SQL.Results 새로운 MySQLHook로에서이다)
Public Function Results(ByVal sql)
Try
Dim conn = Connect()
Dim myAdapter As New MySqlDataAdapter
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sql
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
Return myData
Catch myerror As MySqlException
clsError.logMessage("De server retourneerde de volgende foutmelding: " & myerror.Message)
Return DBNull.Value
End Try
End Function
I olso이 기능을 사용하여 시도하지만 나에게 같은 오류 메시지가 준 :
Public Function num_results(ByVal sql)
Try
Dim conn = Connect()
Dim myAdapter As New MySqlDataAdapter
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sql
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
Return myData
Catch myerror As MySqlException
clsError.logMessage("De server retourneerde de volgende foutmelding: " & myerror.Message)
Return DBNull.Value
End Try
End Function
왜이 변환 오류가 팝업됩니까? 나는 1 또는 0이 자기 설명하는 것이라고 확신했다.
자신에게 유리하게 Option Strict On을 코드 파일이나 프로젝트 설정의 맨 위에 놓습니다. Results 함수에 반환 유형이 지정되지 않았으며 해당 매개 변수에도 유형이 없습니다. 어떻게 컴파일 할 수 있는지 모르겠다. –