sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM ChinaLibClassify WHERE ((id > 1) AND (id < 100)) and (topic1 like TextBox1.Text)";
====>>>>>>>>>>>>>sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM ChinaLibClassify WHERE ((id > 1) AND (id < 100)) and (topic1 like '"+TextBox1.Text+"')";应该这样
====>>>>>>>>>>>>>sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM ChinaLibClassify WHERE ((id > 1) AND (id < 100)) and (topic1 like '"+TextBox1.Text+"')";应该这样
能不能给我推荐一本有SQL语法的C#书或网站,因为我发现这里面的SQL和数据库里的SQL有些不一样
再次感谢
大家能不能推荐一下关于在c#的SQL里写什么时候写“+”什么时候用引号之内的文章
@name
就是这样
Rafe Colburn 著
贺民,邓英材 译
SQL 语法都是一样的!不管在C#,VB,或者其它地方!
string s2=" world";
string s3=s1+s2;
sql的字符串是在“”里面的语句,里面的关键字都是数据库里有的,你不能把控件名写在“”里面的。
string strQuery="select * from table1 where id="+this.textBox1.text
+ " and rq=to_date( ' "+ this.dateTimePicker1.Value.Date.ToString("yyyy-MM-dd")
+"','yyyy-mm-dd')";Oracle 的sql
===>
topic1 like '" + TextBox1.Text + "'"