If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Using a datetime parameter with a stored procedure (VC++)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-14-04, 07:03
Razzer Razzer is offline
Registered User
 
Join Date: May 2004
Posts: 2
Using a datetime parameter with a stored procedure (VC++)

bool CLogBuilderDlg::OpenResultSet( _ConnectionPtr connection, _RecordsetPtr recordset, COleDateTime start_date)
{
_CommandPtr objCmd = NULL;
objCmd.CreateInstance(__uuidof(Command));
_variant_t date;
date = start_date;
date.vt = VT_DATE;

try
{
objCmd->ActiveConnection = connection;
objCmd->CommandText = "get_voted_breakdown_test";
objCmd->CommandType = adCmdStoredProc;
objCmd->Parameters->Append(objCmd->CreateParameter("@start_date", adDate, adParamInput, 8, date));
recordset->CursorLocation = adUseClient;
recordset->Open( (IDispatch *)objCmd, vtMissing, adOpenStatic, adLockReadOnly, adCmdStoredProc );


etc..etc


I get the following error:

Error number 80040e21 [Microsoft] [ODBC SQL server driver] Optional feature not implemented.



the stored procedure is declared as follows:
create procedure get_voted_breakdown_test (@start_date datetime) as
.....

and it works fine if I call it from the query analyser.



Searching the microsoft site I found this comment regarding similar problems with VB.

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.




So what C++ datatype should I be using?





Thanx
Reply With Quote
  #2 (permalink)  
Old 05-14-04, 08:44
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
Code:
objCmd->Parameters->Append(objCmd->CreateParameter("@start_date", adTimestamp, adParamInput, 8, date));
-PatP
Reply With Quote
  #3 (permalink)  
Old 05-18-04, 06:24
Razzer Razzer is offline
Registered User
 
Join Date: May 2004
Posts: 2
Hello Pat,

I've tried your suggestion (well using the adDBTimeStamp datatype)

Now I get a different error from the open.

Error Number 80040e14 procedure get voted breakdown test expects parameter @start_date which was not supplied.
Reply With Quote
  #4 (permalink)  
Old 05-18-04, 09:03
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
Take a look at the CreateParameter example provided in MSDN. In particular, look at the sections right after
Code:
//Define Integer/variant.
to see how they get the parameter from the user and set it up for the call.

Check the parameter type enus to see which one matches the parameter you are supplying.

-PatP
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On