注册 登录
编程论坛 ASP.NET技术论坛

[求助]语法错误!

bavfhpdn66 发布于 2007-04-26 09:45, 804 次点击

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient; //添加类库

public partial class showNews : System.Web.UI.Page
{
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = bc.GetDataSet("select * from tbNews", "news");
DataRow[] row = ds.Tables[0].Select("id="+Request.QueryString["id"]);
foreach (DataRow rs in row)
{
this.Page.Title = rs["title"].ToString();
Label1.Text = rs["title"].ToString();
TextBox1.Text ="  "+ rs["content"].ToString();
}

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("<script language=javascript>window.close()</script>");
}
}

请教高手一下:那一句“红色”提示语法错误——语法错误:“=”运算符后缺少操作数。

怎么改?
谢谢!

8 回复
#2
skyland842007-04-26 10:07
Request.QueryString["id"].Tostring()).
这样就可以了!

因为没有 加的时候 你得到的是一个 object对象!不能直接转换的!
#3
冰残剑2007-04-26 10:25
因该是这样的:
..("id='" + Request.QueryString["id"] + "'");
#4
bavfhpdn662007-04-26 10:56

回2楼:
我按你那样改
错误提示为:未将对象引用设置到对象的实例。

#5
bavfhpdn662007-04-26 10:59
回3楼:
我像你那样改
错误提示为:无法在 System.Int32 和 System.String 上执行“=”操作。
#6
sdlklhd2007-04-26 11:09
将id换成VARCHAR可以吗?
#7
bavfhpdn662007-04-26 11:20

回6楼:
哪个id换掉?

#8
sdlklhd2007-04-26 13:30
把id换成varchar类型试试看,我觉得是类型不匹配
#9
bavfhpdn662007-06-13 16:44
弄好
谢谢
1