请问这是什么错误,应如何解决?
代码:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312"%>
<%@ import namespace="system"%>
<%@ import namespace="system.data"%>
<%@ import namespace="system.data.sqlclient"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" Debug="true">
<title>test</title>
<script language="VB" runat="server">
sub check(sender as object,e as eventargs)
if request.form("txtname")="" or request.form("txtpsd")="" then
lbl.text="姓名和密码都不能为空!"
else
dim myconnection as sqlconnection
dim mycommand as sqlcommand
dim mydatareader as sqldatareader
dim tname as string=request.form("txtname")
dim tpsd as string=request.form("txtpsd")
dim mcmd as string="select id from message" _
&"where id='"& tname &"'" _
&" and where password='"& tpsd &"'"
myconnection=new sqlconnection("server=localhost;uid=sa;pwd=;database=lp")
mycommand=new sqlcommand(mcmd,myconnection)
mycommand.connection.open()
mydatareader=mycommand.executereader()
if mydatareader.read() then
response.Redirect("http://localhost/myweb/main.aspx")
else
lbl.text="对不起,请确认您输入的姓名和密码是否正确!"
end if
end if
end sub
</script>
</head>
<body onLoad="form.txtname.focus()">
<form id="form" action="" method="post" name="form" runat="server">
姓名:<asp:textbox Columns="20" ID="txtname" MaxLength="20" Rows="1" runat="server" TextMode="SingleLine" /><br>
密码:<asp:textbox Columns="20" ID="txtpsd" MaxLength="20" Rows="1" runat="server" TextMode="Password" /><br>
<asp:button ID="btn" runat="server" Text="登陆" OnClick="check"/><br>
<asp:label ID="lbl" runat="server"></asp:label>
</form>
</body>
</html>
错误提示:
Server Error in '/' Application.
--------------------------------------------------------------------------------
第 1 行: '=' 附近有语法错误。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[SqlException: 第 1 行: '=' 附近有语法错误。]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723
System.Data.SqlClient.SqlCommand.ExecuteReader() +42
ASP.TMP1qc3rpiwz2_aspx.check(Object sender, EventArgs e) +409
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
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573