关于session的问题
l80d 2004-08-28 04:20:02 Sub Login(ByVal Sender as Object, ByVal E as EventArgs)
Dim ConnStr As String
ConnStr = "Data Source = localhost;Persist Security Info=False;uid=Gavin;pwd=123456;"
ConnStr = ConnStr + "Initial Catalog=mrc"
Dim Conn As SqlConnection = New SqlConnection(ConnStr)
Conn.Open()
dim Cstring as string
Cstring = "SELECT * FROM user where UserID = '"
Cstring = Cstring + TB_user.text
Cstring = Cstring + "'And Pwd = '"
Cstring = Cstring + TB_pwd.text
Cstring = Cstring + "'"
Dim da As SqlDataAdapter = New SQLDataAdapter(Cstring,Conn)
Dim ds As New DataSet
da.fill(ds,"UserInfo")
If ds.Tables("UserInfo").Rows.Count = 0 then
Lab_warning.visible = true
Lab_warning.text = "对不起,您输入的密码不正确,请确认后重新输入!"
Lab_user.visible = true
TB_user.visible = true
TB_user.text = ""
Lab_pwd.visible = true
TB_pwd.visible = true
TB_pwd.text = ""
But_Login.visible = true
Else
Session("UserName") = ds.Tables("UserInfo").Rows(0).Item("UserID")
Lab_user.visible = false
TB_user.visible = false
Lab_pwd.visible = false
TB_pwd.visible = false
But_Login.visible = false
Lab_warning.visible = true
Lab_warning.text = "您输入的密码正确,可以使用本系统进行编辑!"
End If
End Sub
请问为什么编译的时候会有下面的报错?
在关键字 'user' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 在关键字 'user' 附近有语法错误。
源错误:
行 135: Dim da As SqlDataAdapter = New SQLDataAdapter(Cstring,Conn)
行 136: Dim ds As New DataSet
行 137: da.fill(ds,"UserInfo")
行 138: If ds.Tables("UserInfo").Rows.Count = 0 then
行 139: Lab_warning.visible = true
源文件: c:\inetpub\wwwroot\MRC\index.aspx 行: 137
堆栈跟踪:
[SqlException: 在关键字 'user' 附近有语法错误。]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
ASP.index_aspx.Login(Object Sender, EventArgs E) in c:\inetpub\wwwroot\MRC\index.aspx:137
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277