一个ASP。NET的语法错误请高手近来看看那里写错了 ~!谢谢 rdcustomer = cmcustomer.ExecuteReader(CommandBehavior.CloseConnection)总提示我这句 不对!~为什么 请高手指教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 第 1 行: '=' 附近有语法错误。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。源错误: 行 54: cnNorthWind.Open()行 55: Dim rdcustomer As SqlDataReader行 56: rdcustomer = cmcustomer.ExecuteReader(CommandBehavior.CloseConnection)行 57: If rdcustomer.Read Then行 58: txCustomerID.Text = rdcustomer.GetString(0) 源文件: E:\www\WebApplication3\WebForm1.aspx.vb 行: 56 堆栈跟踪: [SqlException: 第 1 行: '=' 附近有语法错误。] System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) WebApplication3.WebForm1.bnsearch_Click(Object sender, EventArgs e) in E:\www\WebApplication3\WebForm1.aspx.vb:56 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() -------------------------------------------------------------------------------- scommandText = "select customerID,companyname,contactname,phone,fax from customers"--->scommandText = "select customerID,companyname,contactname,phone,fax from customers "最后加个空格试试 scommandText = scommandText & "where customerID=" & txparameter.Text如果customerID是int, 不需要单引号 scommandText = scommandText & "where comanyname like '" & txparameter.Text & "'"---》scommandText = scommandText & "where comanyname like '%" & txparameter.Text & "%'" 获取浏览器地址栏地址 请教大师们一个正则表达式的问题 css样式里怎么会有大于号? 百分求怎么分辨浏览器上来的的请求是图片的请求还是点链接的网页请求? 如何使Datagrid选中页的页码不显示下划线? xp pro 上架iis,访问html.txt文件没问题,访问asp文件却总是错误500? 在web.config中如何写相对路径! 插入数据成功后,刷新网页,数据又写入一次,怎么解决 请教页面的刷新问题? Duwamish7实在太复杂了,有没有更简单点的项目分析? web进销存 多个文件引用一个同样的一段代码,怎样处理比较好
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。源错误:
行 54: cnNorthWind.Open()
行 55: Dim rdcustomer As SqlDataReader
行 56: rdcustomer = cmcustomer.ExecuteReader(CommandBehavior.CloseConnection)
行 57: If rdcustomer.Read Then
行 58: txCustomerID.Text = rdcustomer.GetString(0)
源文件: E:\www\WebApplication3\WebForm1.aspx.vb 行: 56 堆栈跟踪:
[SqlException: 第 1 行: '=' 附近有语法错误。]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
WebApplication3.WebForm1.bnsearch_Click(Object sender, EventArgs e) in E:\www\WebApplication3\WebForm1.aspx.vb:56
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()
--------------------------------------------------------------------------------
--->
scommandText = "select customerID,companyname,contactname,phone,fax from customers "
最后加个空格试试
如果customerID是int, 不需要单引号
---》
scommandText = scommandText & "where comanyname like '%" & txparameter.Text & "%'"