我在ASP.NET登錄表單上的標題中收到錯誤消息有人知道我該如何解決它?幫助深表感謝從字符串「」轉換爲「布爾型」類型無效
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim conn As New MySqlConnection
conn.ConnectionString = ("server=localhost;port=3307;user=user;password=password;database=DB;")
Try
Dim SQL As String = "select * from users3 where uname = '" & txtUName.Text & "' AND password = '" & txtPwd.Text & "'"
conn.Open()
Dim cmd As New MySqlCommand(SQL, conn)
Dim reader As MySqlDataReader = cmd.ExecuteReader
reader.Read()
Dim isValidLogin As Boolean
Boolean.TryParse(reader.GetValue(1), isValidLogin)
If isValidLogin Then
Session("UserName") = txtUName.Text
Response.Redirect("REGISTERPROP.aspx")
Else
Response.Write("Invalid Login")
End If
Catch ex As Exception
Response.Write("An Error Occurred: " & ex.Message.ToString())
End Try
End Sub
可能重複[從字符串到boolean類型的轉換是無效的(http://stackoverflow.com/questions/7874049/conversion-from-string-to-type -boolean-is-not-valid) –
該問題已解決,我認爲我沒有收到錯誤消息,但現在正在獲取此「在調用Read()之前訪問字段的無效嘗試」在asp上很虛弱。網和幫助非常感謝! – user3457014
請將此問題設置爲回答,並在發佈當前代碼時提出新問題。 – NotMe