简单的C#SQL查询语句错误(急)
string strsql = "select * from sale_view where [date] >='" + this.dateTimePicker1.Value.ToShortDateString()+ " 00:00:00 '"and [date]< ='" + dateTimePicker1.Value.ToShortDateString() + "23:59:59'";请大家帮我改正一下
谢谢了
--------------------编程问答-------------------- string strsql = "select * from sale_view where [date] between '" + this.dateTimePicker1.Value.ToShortDateString()+ " 00:00:00 ' and" + '" +dateTimePicker1.Value.ToShortDateString() + "23:59:59'";
--------------------编程问答-------------------- datetime类型的要用''引起来了 --------------------编程问答-------------------- 1.
string strsql = "select * from sale_view where [date] >='"+ dateTimePicker1.Value.ToShortDateString() + " 00:00:00'" and [date]<='"+ dateTimePicker1.Value.ToShortDateString() + " 23:59:59'";
2.
string strsql = "select * from sale_view where [date] between '"+ dateTimePicker1.Value.ToShortDateString() + " 00:00:00'" and '"+ dateTimePicker1.Value.ToShortDateString() + " 23:59:59'";
这两个都可以. --------------------编程问答-------------------- string strsql = "select * from sale_view where DATEADD(dd, 0, DATEDIFF(dd, 0, [date])) ='" + DateTime.Today.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + "'"; --------------------编程问答-------------------- 这不知道 你这包的什么错误
但很明显 最后一个 判断 时间 拼串的地方 缺了个空格 --------------------编程问答--------------------
补充:.NET技术 , Web Services