日期更新问题,高手们帮帮忙?

rhs 2004-04-28 01:02:30
结果是:“标准表达式中数据类型不匹配”。但是voteData字段类型是短日期型,按理由就没错啊。究竟是哪错了??
try
{
this.conn.Open();
System.Data.OleDb.OleDbDataAdapter DA = new OleDbDataAdapter("select * from tblmember",this.conn);
System.Data.OleDb.OleDbCommand Com = new OleDbCommand();
Com.Connection = this.conn;
Com.CommandText = "update tblmember set voteDate ="+ @System.DateTime.Today.ToShortDateString() +" where ID = " + this.userID;
DA.UpdateCommand = Com;
Com.ExecuteNonQuery();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
this.conn.Close();
}
...全文
116 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
rhs 2004-04-28
  • 打赏
  • 举报
回复
To SimerJoe(浪月):就你说的应改成OleDbType吧,但可是获取系统日期哦。
SimerJoe 2004-04-28
  • 打赏
  • 举报
回复
System.DateTime.Today.ToShortDateString() //这里错了。
改成SqlType命名空间里的日期类型。
foreverandever 2004-04-28
  • 打赏
  • 举报
回复
"update tblmember set voteDate =to_date('"+ @System.DateTime.Today.ToShortDateString() +"','dd/mm/yyyy') where ID = " + this.userID;
rhs 2004-04-28
  • 打赏
  • 举报
回复
不行啊,Today.Date.ToShortDateString()就是不是返回“短日期型”即2004-4-28的吗。而这个字段也是这样类型怎么会借的呢??
zhoutong78 2004-04-28
  • 打赏
  • 举报
回复
DateTime.Today.Date.ToShortDateString()
rhs 2004-04-28
  • 打赏
  • 举报
回复
我照两位所说必过程序,但是结果还是是:“标准表达式中数据类型不匹配”。
ToShortDateString()本身都是返回string类型,我想问题不是在这儿吧。
icehawk 2004-04-28
  • 打赏
  • 举报
回复
"update tblmember set voteDate ='"+ @System.DateTime.Today.ToShortDateString() +"' where ID = " + this.userID;
bitsbird 2004-04-28
  • 打赏
  • 举报
回复
@System.DateTime.Today.ToShortDateString()
-------------------------------------
@System.DateTime.Today.ToShortDateString().ToString()

111,119

社区成员

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

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

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