ADO中执行存储过程如何传递datetime类型?

s5689412 2006-07-05 08:26:35
bool db_set_inform_device(time_t CurrentTime)
{
COleDateTime currentTime(CurrentTime);
CADOParameter paramCurrentTime(CADORecordset::typeDate, sizeof(DATE));
paramCurrentTime.SetValue(currentTime);
......
}

在执行的时候老是报数据超出范围的错误0x80040e21,有没有谁遇到过类似问题?
我使用的是codeproject上封装的ado类。
...全文
330 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
黑子白子 2006-07-10
  • 打赏
  • 举报
回复
ado通用变量类型是_variant_t(也是COM通用类型),转换为_variant_t类型即可,具体看MSDN吧。
Yang_ 2006-07-07
  • 打赏
  • 举报
回复
我的意思是,这样就不必使用CADOParameter,CADOCommand了

Yang_ 2006-07-07
  • 打赏
  • 举报
回复
一般来说,执行存储过程可以简单的传送sql语句
exec procname 参数

exec procname '2006-7-1'


s5689412 2006-07-06
  • 打赏
  • 举报
回复
已经找到错误源头,因为SQL Server不支持adDate数据类型,所以要改用typeDBTimeStamp。

具体见KB:Q214459

When the sample code is run, it gives this error:
Run-time error '2147217887 (80040e21)':
[Microsoft][ODBC SQL Server Driver] Optional feature not Implemented.
This is because SQL Server does not support the adDBDate datatype. To correct this problem, change the datatype of the @theDate parameter to adDBTimeStamp.

In order to determine the number, names, types, and sizes of parameters needed in a stored procedure, use the Parameters.Refresh method of the command object. You can call this method during development of your application to determine the correct requirements for the stored procedure, then remove the expensive call to Parameters.Refresh after you have gathered the necessary data.

4,018

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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