日期:2014-05-18  浏览次数:20972 次

C#中的SQL like查询语句怎么写??
在SQL中写的是select * from detail where date like '%2012%' and money like '%100%'

在C#中想用textbox1和textbox2两个控件的值来代替2012和100.....遇到百分号和单引号那里就卡住出错了~~~能给我指出应该怎么写吗~~

------解决方案--------------------
sql = "select * from detail where date like '%" + textBox1.Text + "%' and money like '%" + textBox2.Text + "%'"
------解决方案--------------------
C# code

"select * from detail where date like '%" + textBox1.Text.Trim() + "%' and money like '%" textBox2.Text.Trim() +"%'"