C#数据库查询

xiangz123 2004-04-22 06:40:36
各位大侠:
用C#操作Access时(主题查询):
cmdText="select * from tablename where colname like \'*"+this.textBox1.text+"\'*";
为什么返回的是一空表呢?????也用过‘%’
...全文
39 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
BestSky 2004-04-23
  • 打赏
  • 举报
回复
select id from linktest where name like '"+textbox.text+"*'"或者
select id from linktest where name like '"+textbox.text+"%'"
'\'不用.
eric88 2004-04-23
  • 打赏
  • 举报
回复
把你的sql语句粘贴到查询分析器执行一下就知道里
zxfox 2004-04-22
  • 打赏
  • 举报
回复
有个问题啦,你写的是SQL语句,用于在数据库中调用数据,为什么要加保留符“\“啦。
黄金安魂曲 2004-04-22
  • 打赏
  • 举报
回复
select语句不对,按下面写,可以模糊查找TextBox1中的内容。
SELECT * FROM tablename WHERE columnname LIKE '%" +
this.TextBox.Text.Trim() + "%'"
limer 2004-04-22
  • 打赏
  • 举报
回复
up!
lizhongkun 2004-04-22
  • 打赏
  • 举报
回复
cmdText="select * from tablename where colname like '*"+this.textBox1.text+"*'";
就对了!
bullion 2004-04-22
  • 打赏
  • 举报
回复
或者把语句改一下:
cmdText="select * from tablename where colname like '*"+this.textBox1.text+"*'";
bullion 2004-04-22
  • 打赏
  • 举报
回复
你先试一下这样写:
cmdText="select * from tablename where colname like '%%'";
如果没有错误的话,那就是你语句的问题了
2thaugust 2004-04-22
  • 打赏
  • 举报
回复
SQL表达式写的不对!!
xiangz123 2004-04-22
  • 打赏
  • 举报
回复
搜索含有textBox1中内容的所有项

110,534

社区成员

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

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

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