Public Class Login
Inherits System.Web.UI.Page
Dim connectionString As String = "Data Source=*****;Initial Catalog=AlphaSYS39414;Persist Security Info=True;User ID=******;Password=********"
Protected Sub btnlogin_Click(sender As Object, e As EventArgs) Handles btnlogin.Click
Using connection As New SqlConnection(connectionString)
Dim account As String = txtusername.Text
Dim mypassword As String = txtpassword.Text
Dim sqlCommand As New _
SqlCommand("SELECT * FROM User WHERE @User_ID AND @Password", connection)
sqlCommand.Parameters.AddWithValue("@User_ID", account)
sqlCommand.Parameters.AddWithValue("@Password", mypassword)
connection.Open()
**Dim reader As SqlDataReader = sqlCommand.ExecuteReader()**
Dim values As New ArrayList()
If reader.Read Then
Response.Redirect("https://google.com")
'Dim returnedUsername As New String(reader("account"))
'Dim returnedPassword As New String(reader("mypassword"))
Else
Response.Redirect("https://yahoo.com")
End If
End Using
End Sub
End Class
User
是此链接上列出的保留关键字。
您应该更改此代码
SqlCommand("SELECT * FROM User WHERE @User_ID AND @Password", connection)
对此
SqlCommand("SELECT * FROM [User] WHERE @User_ID AND @Password", connection)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句