string strSql = string.Format("SELECT PRICE FROM PRODUCTS WHERE PRICE BETWEEN {0} AND {1}",TextBox1.Text,TextBox2.Text);
string sqltext="select price from products where price between " + TextBox1.Text + " and " + TextBox2.Text; ================================================================================================ string strSql =string.Format(@“ select price from products where price between {0} and {1}”,TextBox1.Text,TextBox2.Text);
string sqltext="select price from products where price between '" + TextBox1.Text + "' and '" + TextBox2.Text+"'";
=string.Format(@“ select price from products where price between {0} and {1}”,TextBox1.Text,TextBox2.Text)
跟平常写的一样,就是条件参数化楼上都有直接的sql,你也可以参照参数化的sql字符串
================================================================================================
string strSql
=string.Format(@“ select price from products where price between {0} and {1}”,TextBox1.Text,TextBox2.Text);