Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = " " Or TextBox2.Text = " " Then
Label1.Text = "必须输入帐号和密码!"
Exit Sub
Else
conn.Open()
cmd.CommandText = "select 昵称 from member where 昵称='" & Trim(TextBox1.Text) & "' and 密码='" & Trim(TextBox2.Text) & "'"
Dim objreader As System.Data.OleDb.OleDbDataReader = cmd.ExecuteReader()
If objreader.Read() Then
Session("mem") = TextBox1.Text
Label1.Text = "登录成功!"
TextBox1.Text = " "
TextBox1.Enabled = False
TextBox2.Text = " "
TextBox2.Enabled = False
Else
Label1.Text = "昵称不存在或密码不正确!"
End If
conn.Close()
End If
End Sub
上面这段程序是一段登录程序,问什么我一运行,红色那一行就出错阿错误为:
----------------------------------------------------------------------------------------------------------------------------
“/WebApplication12”应用程序中的服务器错误。
标准表达式中数据类型不匹配。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 标准表达式中数据类型不匹配。
源错误:
行 55: conn.Open()
行 56: cmd.CommandText = "select 昵称 from member where 昵称='" & Trim(TextBox1.Text) & "' and 密码='" & Trim(TextBox2.Text) & "'"
行 57: Dim objreader As System.Data.OleDb.OleDbDataReader = cmd.ExecuteReader()
行 58: If objreader.Read() Then
行 59: Session("mem") = TextBox1.Text
源文件: c:\inetpub\wwwroot\WebApplication12\WebForm1.aspx.vb 行: 57
堆栈跟踪:
[OleDbException (0x80040e07): 标准表达式中数据类型不匹配。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
System.Data.OleDb.OleDbCommand.ExecuteReader()
WebApplication12.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication12\WebForm1.aspx.vb:57
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()