日期:2014-05-19  浏览次数:20789 次

请帮忙 在c#中sql语句写法
请问
string   sqlStr= "select   city,city1,addr2   from   postcode   where   code= "&this.tb1.Text& " ";
其中this.tb1.Text是一个textbox的文本,编译无法通过,请问我该如何写
谢谢

------解决方案--------------------
string sqlStr= "select city,city1,addr2 from postcode where code= ' "+this.tb1.Text+ " ' ";
------解决方案--------------------
string sqlStr= "select city,city1,addr2 from postcode where code= " + this.tb1.Text;

------解决方案--------------------
一楼是文本类型,也可是time类型,二楼是数值类型,看你的code类型,选择使用。记得给分。

------解决方案--------------------
string sqlStr= "select city,city1,addr2 from postcode where code= ' "+this.tb1.Text+ " ' ";
這也太簡單了吧!!!
------解决方案--------------------
string sqlStr= "select city,city1,addr2 from postcode where code= ' "+this.tb1.Text+ " ' ";
------解决方案--------------------
string sqlStr= "select city,city1,addr2 from postcode where code= ' "+this.tb1.Text+ " ' ";
应该是这个