SQL查询语句语法错误,找不出来!请教高手!

benbenRH 2009-11-07 10:12:57
string cmdText = "select attentiontime, nickname, message from message,person where attentiontime>=" + DateTime.Now + " and attentiontime=<" + DateTime.Now.AddDays(1) + " and message.personid=person.id";

语法错误:
where attentiontime>=" + DateTime.Now + " and attentiontime=<" + DateTime.Now.AddDays(1) + " and message.personid=person.id";
...全文
98 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
benbenRH 2009-11-07
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 huangzhe10 的回复:]
attentiontime= <
有这样的写法??!?!
[/Quote]

呵呵,给你看出来了,就是>= 写成了=>,这个出错了!谢谢各位
benbenRH 2009-11-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lixinramaxel41658133 的回复:]
改成:
where attentiontime>='" + DateTime.Now.ToString() + "' and attentiontime <='" + DateTime.Now.AddDays(1).ToString() + "' and message.personid=person.id";
试一试
[/Quote]
[Quote=引用 2 楼 gw_tong 的回复:]
DateTime.Now
改成=>DateTime.Now.ToString(strFormat)
试试看

[/Quote]
两种方法都不行!
huangzhe10 2009-11-07
  • 打赏
  • 举报
回复
attentiontime= <
有这样的写法??!?!
gw_tong 2009-11-07
  • 打赏
  • 举报
回复
DateTime.Now
改成=>DateTime.Now.ToString(strFormat)
试试看
  • 打赏
  • 举报
回复
改成:
where attentiontime>='" + DateTime.Now.ToString() + "' and attentiontime<='" + DateTime.Now.AddDays(1).ToString() + "' and message.personid=person.id";
试一试

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧