关于一个棘手的SQL
语句如下
SELECT * FROM ZZ WHERE DT>=" + dta + " and DT<=" + dtb + " and NUM-1=" + comboBox1.SelectedIndex + " order by DT
DT是ORACLE数据库里面的时间字段,类型是date
dta,dtb两个变量是两个dateTimePicker的value;
在数据库里面运行不了
"SELECT * FROM ZZ WHERE DT>=2011/12/5 19:59:56 and DT<=2011/12/18 19:59:56 and NUM-1=0 order by DT"
我知道可以用SQL语法中的to_date转换成功
但我不知道在Visual Studio9.0 C#中怎么改?
请教各位大侠如何配置此SQL语句
------解决方案--------------------日期要加引号
SELECT * FROM ZZ WHERE DT>='" + dta + "' and DT<='" + dtb + "' and NUM-1=" + comboBox1.SelectedIndex + " order by DT
SQL code
SELECT * FROM ZZ WHERE DT>='2011/12/5 19:59:56' and DT<='2011/12/18 19:59:56' and NUM-1=0 order by DT
------解决方案--------------------
sql string 拼接时
非INT字段要加上单引号
形如1楼所写
------解决方案--------------------
SQL code
SELECT
*
FROM
ZZ
WHERE
DT>='cast(2011/12/5 19:59:56 as detetime)'
and
DT<='cast(2011/12/18 19:59:56 as datetime)'
and
NUM-1=0 order by DT