Unable to pass DBDATE to stored-proc using ADO/C++
- From: "asnowfall@xxxxxxxxx" <asnowfall@xxxxxxxxx>
- Date: Thu, 08 Nov 2007 22:41:41 -0000
I am trying to pass DBDATE to a stored procedure but raw_Execute() is
failing with DB_E_ERRORSOCCURRED.
My stored-procedure is simple.
------------------------------------------------
ALTER PROCEDURE [dbo].[sp_update_date]
@e_id VARCHAR(255),
@e_date DATETIME
AS
BEGIN
SET NOCOUNT ON;
END
C++ code that calling this.
----------------------------------------
time_t oTime;
.......
.....
vtE_date.vt = VT_DATE;
Time_tToVTime( oTime, &vtE_date.date);
pCmd->ActiveConnection= pConn;
pConn->CommandTimeout = 120*60;
pCmd->CommandTimeout = 120*60;
pCmd->CommandType = adCmdStoredProc;
pCmd->CommandText = _bstr_t("sp_update_date");
pParameter = pCmd->CreateParameter(_bstr_t("@e_id"),
adVarChar,adParamInput,255);
pCmd->Parameters->Append(pParameter);
pParameter->Value = vtEId;
pParameter = pCmd->CreateParameter(_bstr_t("@e_date"),
adDate,adParamInput,sizeof(double));
pCmd->Parameters->Append(pParameter);
pParameter->Value = vtE_date;
hr = pCmd->raw_Execute(&nCount,NULL,adCmdStoredProc,NULL); //Returns
DB_E_ERRORSOCCURRED
.....
.....
Time_tToVTime( __int64 oTime, double* objVarTime)
{
SYSTEMTIME objSysTime;
tm* ptm = _localtime64(&oTime);
memset(&objSysTime,0, sizeof(SYSTEMTIME));
objSysTime.wYear = (WORD) (1900 + ptm->tm_year);
objSysTime.wMonth = (WORD) (1 + ptm->tm_mon);
objSysTime.wDayOfWeek = (WORD) ptm->tm_wday;
objSysTime.wDay = (WORD) ptm->tm_mday;
objSysTime.wHour = (WORD) ptm->tm_hour;
objSysTime.wMinute = (WORD) ptm->tm_min;
objSysTime.wSecond = (WORD) ptm->tm_sec;
SystemTimeToVariantTime(&objSysTime, objVarTime)
}
Before calling raw_Execute(), the value stored in VARIANT.date looked
ok.
I created an another stored-proc without DBDATE parameter and
raw_Execute() succeeded; and this proves that I am doing something
wrong when sending DBDATE, please let me know what I am doing wrong..
Thanks
Ramesh
.
- Follow-Ups:
- Re: Unable to pass DBDATE to stored-proc using ADO/C++
- From: Bob Barrows [MVP]
- Re: Unable to pass DBDATE to stored-proc using ADO/C++
- Prev by Date: Re: ADOX - Access table creation with nullable columns.
- Next by Date: Re: Unable to pass DBDATE to stored-proc using ADO/C++
- Previous by thread: Re: ADOX - Access table creation with nullable columns.
- Next by thread: Re: Unable to pass DBDATE to stored-proc using ADO/C++
- Index(es):