Problem calling a stored procedure



Hi!
I have a method which i have used for a long time passing ordinary sql
expressions (SELECT,INSERT, UPDATE and so on) to databases. But now im
forced to call a stored procedure in SQL Server. So i thought i'd use
the same code. But it doesnt work. I always get error -2147217887 when
running ICommandText->Execute. Can anyone please look att the code
snippet below and see if you can figure out what is wrong? Any help is
most appriciated!

ExecuteStoredProcedure(TCHAR *command)
{
//command value is EXEC proc_itemtest 'R' ,0
HRESULT ret_val = 0L;
WCHAR *cmd_str = 0L;
int jj = 0;
int i= 0;


m_ColOffset = 0;


// Obtain a pointer of IDBCreateSession interface
if ( FAILED( m_Interface->QueryInterface( IID_IDBCreateSession,

(void**) &m_IDBCreateSession ) ) )
{
...
}


// Create a session with database
if ( FAILED( m_IDBCreateSession->CreateSession( NULL,
IID_IDBCreateCommand, (IUnknown**) &m_IDBCreateCommand ) ) )
{
...
}
m_IDBCreateSession->Release();
m_IDBCreateSession = 0L;


// Create a command to execute SQL statement
if ( FAILED( m_IDBCreateCommand->CreateCommand( NULL,
IID_ICommandText, (IUnknown **) &m_ICommandText ) ) )
{
....
}
m_IDBCreateCommand->Release();
m_IDBCreateCommand = 0L;


ToUnicode( &cmd_str, command );


// Set command properties
if ( !FAILED( m_ICommandText->QueryInterface(
IID_ICommandProperties,
(void **) &m_ICommandProperties ) ) )
{
CMOOLEDB_PROPSFLAGS
crs_props[CMOOLEDBQUERY_NOFCOMMANDPROPS] = {
// {DBPROP_SERVERCURSOR, true},
// {DBPROP_CLIENTCURSOR, true},
// {DBPROP_DEFERRED, false},
// {DBPROP_IRowsetChange, false},
// {DBPROP_IRowsetLocate, false},
// {DBPROP_IRowsetScroll, false},
// {DBPROP_IRowsetUpdate, false},
// {DBPROP_BOOKMARKS, false},
// {DBPROP_CANFETCHBACKWARDS, false},
// {DBPROP_CANSCROLLBACKWARDS, false},
{DBPROP_CANHOLDROWS, true},
// {DBPROP_LITERALBOOKMARKS, false},
// {DBPROP_OTHERINSERT, true},
// {DBPROP_OTHERUPDATEDELETE, true},
// {DBPROP_OWNINSERT, true},
// {DBPROP_OWNUPDATEDELETE, true},
// {DBPROP_QUICKRESTART, false},
// {DBPROP_IRowsetResynch, false},
// {DBPROP_CHANGEINSERTEDROWS, false},
// {DBPROP_SERVERDATAONINSERT, false},
// {DBPROP_UNIQUEROWS, false},
// {DBPROP_IMMOBILEROWS, false},
// {DBPROP_IMultipleResults, false},
// {DBPROP_ABORTPRESERVE, true},
// {DBPROP_COMMITPRESERVE, true}
};


for ( i = 0; i < 1; i++ )
{
VariantInit( &m_RowProp[i].vValue );
m_RowProp[i].dwOptions = DBPROPOPTIONS_REQUIRED;
m_RowProp[i].colid = DB_NULLID;
m_RowProp[i].dwPropertyID = crs_props[i].m_PropId;
m_RowProp[i].vValue.vt = VT_BOOL;
m_RowProp[i].vValue.boolVal = crs_props[i].m_Val ?
VARIANT_TRUE : VARIANT_FALSE;
}


m_PropSet.rgProperties = m_RowProp;
m_PropSet.cProperties =
CMOOLEDBQUERY_NOFCOMMANDPROPS;
m_PropSet.guidPropertySet = DBPROPSET_ROWSET;
ret_val = m_ICommandProperties->SetProperties( 1,
&m_PropSet );


m_ICommandProperties->Release();
m_ICommandProperties = 0L;


}


// Set the command text to SQL statment
if ( FAILED( m_ICommandText->SetCommandText( DBGUID_DBSQL, cmd_str
) ) )
{..}


// Execute the command
if ( FAILED( ret_val = m_ICommandText->Execute( NULL,
IID_IRowset,
NULL, m_NumRows,(IUnknown **) &m_Rowset ) ) ) // Resultset pointer
{..}
m_ICommandText->Release();
m_ICommandText = 0L;


.....

.



Relevant Pages

  • Re: COBOL stored procedure for DB2
    ... Regarding how you precompile the app, you must specify target mfcob to db2 prep, rather than target ibmcob. ... Have you also confirmed that, prior to executing the CALL statement, the host variables specified within the client app have the appropriate values? ... MODIFIES SQL DATA ... confirm the cob command used for creating the SP module. ...
    (comp.lang.cobol)
  • Re: COBOL stored procedure for DB2
    ... Have you also confirmed that, prior to executing the CALL statement, the ... The DB2 CREATE PROCEDURE statement. ... MODIFIES SQL DATA ... confirm the cob command used for creating the SP module. ...
    (comp.lang.cobol)
  • Re: Can I get Consultancy advice on SQL/Fox in the UK (South East)
    ... My problem is the two Sequel Server tables within one database with which I ... Don't ask me why but the SQL designers have NOT ... command that I can initiate with SQLCONNECT, ... > While you're in the View Designer, right-click and view the SQL code. ...
    (microsoft.public.fox.helpwanted)
  • Re: Optimistic Concurrency on UpdateCommand...
    ... client device, I update that column with a non-null datetime and then try to ... 1!!!If I copy and paste the command ... With the 4th column not allowing nulls, the optimistic concurrency code ... Can I have a nullable datetime column in my Sql ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Select - SQL vs. SUM
    ... If you have to use an earlier version of VFP earlier than 9, ... >> also force VFP to read from the buffer with a new clause in the SQL ... >> The SELECT command doesn't move the record pointer in the grid's record ... >>> I have a grid whose recordsource is a table named _payments. ...
    (microsoft.public.fox.programmer.exchange)