SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);',' 附近有语法错误.

从另一个页面的gridview中获取一条信息的ID值,但提示有语法错误,到底哪里错了啊?求大神搭救啊protectedvoidPage_Load(objectsender... 从另一个页面的gridview中获取一条信息的ID值,但提示有语法错误,到底哪里错了啊?求大神搭救啊
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["ID"] != null)//修改操作
{
int nid = int.Parse(Request.QueryString["ID"].ToString());
//然后去取数据;
SqlConnection conn = new SqlConnection("Data Source=MICROSOF-0EB1C6;Initial Catalog=shijin;Integrated Security=True");
conn.Open();
SqlCommand cmd = new SqlCommand("select (infotitle,infomsg,lostadd,contactadd,contactperson,mobile,qq) from lostinfo where ID='"+ nid +"'", conn);

SqlDataReader Dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

if (Dr.Read())
{
this.TextBox1.Text =Dr["infotitle"].ToString();
this.TextBox2.Text =Dr["infomsg"].ToString();
this.TextBox3.Text =Dr["lostadd"].ToString();
this.TextBox4.Text =Dr["contactadd"].ToString();
this.TextBox5.Text =Dr["contactperson"].ToString();
this.TextBox6.Text =Dr["mobile"].ToString();
this.TextBox8.Text =Dr["qq"].ToString();

}
conn.Close();
展开
 我来答
布萌布咕咕
2014-05-15 · 超过27用户采纳过TA的回答
知道答主
回答量:36
采纳率:0%
帮助的人:53万
展开全部
new SqlCommand("select (infotitle,infomsg,lostadd,contactadd,contactperson,mobile,qq) from lostinfo where ID='"+ nid +"'", conn);的select (infotitle,infomsg,lostadd,contactadd,contactperson,mobile,qq) from lostinfo where ID='"+ nid +"'"
括号去掉。

if (Dr.Read())
改为 while(Dr.Read())
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式