')' 附近的语法不正确。
说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.Data.SqlClient.SqlException:')' 附近的语法不正确。
错误来源:
Dim cmd As SqlCommand = New SqlCommand(checkuser, con)
Dim temp As Integer = Convert.ToInt32(cmd.ExecuteScalar().ToString())
con.Close()
完整代码:
Protected Sub Buttonlogin_Click(sender As Object, e As EventArgs) Handles Buttonlogin.Click
If (Page.IsPostBack) Then
Dim con As New SqlConnection("Data Source=.;Initial Catalog=DMS;User ID=sa;Password=football2u")
con.Open()
Dim checkuser As String = "Select count from DMSRegform where Username ='" + TextBoxuser.Text + "')"
Dim cmd As SqlCommand = New SqlCommand(checkuser, con)
Dim temp As Integer = Convert.ToInt32(cmd.ExecuteScalar().ToString())
con.Close()
If temp = 1 Then
con.Open()
Dim checkpasswordquery As String = "Select password from DMSRegform Where Username ='" + TextBoxpass.Text + "')"
Dim Passwordcmd As SqlCommand = New SqlCommand(checkpasswordquery, con)
Dim password As String = Passwordcmd.ExecuteScalar().ToString()
If password = TextBoxpass.Text Then
'Session["New"] = Textboxuser.text
Response.Write("Password correct")
Else
Response.Write("Password is incorrect")
End If
Else
Response.Write("Username is incorrect")
End If
End If
End Sub
Dim checkuser As String = "Select count from DMSRegform where Username ='" + TextBoxuser.Text + "')"
....
Dim checkpasswordquery As String = "Select password from DMSRegform Where Username ='" + TextBoxpass.Text + "')"
为什么)
要在查询中添加final ?删除)
它们中的 ,它应该没问题。
也永远不要使用字符串连接来编写您的查询。使用参数化查询,否则您将接触到 Sql 注入。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句