Mysql vb.net身份验证无效CastException
我正在用vb.net开发一个桌面应用程序。我正在使用windows窗体进行身份验证,我正在使用下面的代码进行身份验证,它显示“datareader(1).ToString=login.Text”中存在invalidcastexception,我在文本区域“admin”中键入了此错误: 字符串“admin”到类型“Boolean”的转换无效Mysql vb.net身份验证无效CastException,mysql,vb.net,winforms,authentication,desktop-application,Mysql,Vb.net,Winforms,Authentication,Desktop Application,我正在用vb.net开发一个桌面应用程序。我正在使用windows窗体进行身份验证,我正在使用下面的代码进行身份验证,它显示“datareader(1).ToString=login.Text”中存在invalidcastexception,我在文本区域“admin”中键入了此错误: 字符串“admin”到类型“Boolean”的转换无效 If datareader.HasRows Then While (datareader.Read())
If datareader.HasRows Then
While (datareader.Read())
If (datareader(1).ToString = login.Text & datareader(2).ToString = password.Text) Then
Me.Close()
FormMenu.Show()
End If
End While
你有没有把这个从C#转换过来?那
&
和那些额外的括号在那里做什么?将和更改为并将其更改为。如果您喜欢括号,请附上2个条件。(顺便说一句,ToString()
是一种方法。我知道,它无论如何都是有效的…)非常感谢
If datareader.HasRows Then
While (datareader.Read())
If datareader(1).ToString = login.Text AndAlso datareader(2).ToString = password.Text Then
Me.Close()
FormMenu.Show()
End If
End While