"=' 附近有语法错误。

renye0907 2009-03-13 05:39:30

string strconn = "server=WWW-51F7B2A9835\\SqlExpress;Initial Catalog=student;Integrated security=SSPI";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
SqlDataAdapter myad = new SqlDataAdapter("select t_no, t_name,t_post from teacher where t_no==num .Text.Tostring() | t_name==name.Text.Tostring() | t_post==zichen.Text.tostring()",conn );
DataSet ds = new DataSet();
myad.Fill(ds, "teacher");
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
}

myad.Fill(ds, "teacher");这句有错
...全文
96 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
renye0907 2009-03-13
  • 打赏
  • 举报
回复
该成你们说的那个样子的话那个Tostring就不行了
changmengmeng 2009-03-13
  • 打赏
  • 举报
回复
select t_no, t_name,t_post from teacher where t_no='"+num .Text.Tostring()+"' t_name='"+name.Text.Tostring()+"' | t_post='"+zichen.Text.tostring()+"'

如果t_no是int型的,就num.text.toint32()
syb1045 2009-03-13
  • 打赏
  • 举报
回复
select t_no, t_name,t_post from teacher where t_no==num .Text.Tostring() | t_name==name.Text.Tostring() | t_post==zichen.Text.tostring()

有用2个‘=’号拼写的?

select t_no, t_name,t_post from teacher where t_no='"+num .Text.Tostring()+"' t_name'"+=name.Text.Tostring()+"' | t_post='"+zichen.Text.tostring()+"'

如果是int型的就去掉 ''

where t_no="+num.Text.Tostring() +"
liu4545533 2009-03-13
  • 打赏
  • 举报
回复
"select t_no, t_name,t_post from teacher where t_no= '"+num .Text.Tostring() "'or t_name='"+name.Text.Tostring() "' or t_post='"zichen.Text.tostring()
liu4545533 2009-03-13
  • 打赏
  • 举报
回复
[Quote=引用楼主 renye0907 的帖子:]

string strconn = "server=WWW-51F7B2A9835\\SqlExpress;Initial Catalog=student;Integrated security=SSPI";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
SqlDataAdapter myad = new SqlDataAdapter("select t_no, t_name,t_post from teacher where t_no==num .Text.Tostring() | t_name==name.Text.Tostring() | t_post==zichen.Text.tostring()",conn );
DataSet ds = new…
[/Quote]
应该为:
"select t_no, t_name,t_post from teacher where t_no="+num .Text.Tostring() "or t_name="+name.Text.Tostring() "or t_post="zichen.Text.tostring()
wb78845838 2009-03-13
  • 打赏
  • 举报
回复
呵呵,字符有这么拼接的吗?
zzxap 2009-03-13
  • 打赏
  • 举报
回复
where t_no=='"+num.Text.Tostring() +"'
cja03 2009-03-13
  • 打赏
  • 举报
回复
"select t_no, t_name,t_post from teacher where t_no==num .Text.Tostring() | t_name==name.Text.Tostring() | t_post==zichen.Text.tostring()"

"select t_no, t_name, t_post from teacher where t_no=" + num.Text + //这个t_no不知道你是不是用int型的
" or t_name = '" + name.Text +"' or t_post = '" + zichen.Text + "'"

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧