Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling SP in DB upsized from MS Access

Status
Not open for further replies.

solla

Programmer
Feb 21, 2003
19
FR
Hello,

I inherited an Access database with a bunch of stored procedures and some working ADO/C++ code to call them.

I upsized the database to an SQL Server database and everything seems to be fine (i.e, all the info has transferred).

I now want to use the same code to call the stored procedures. In particular, the stored procedure in Access reads:

SELECT DISTINCT UM_Groups_T.Id
FROM UM_Groups_T
WHERE (UM_Groups_T.Name=reqGroupName);

with a single input parameter, reqGroupName.

In the SQL server database, this has been translated to a user-defined function,

********************************************************
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[UM_GetGroupID_Q]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[UM_GetGroupID_Q]
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE FUNCTION UM_GetGroupID_Q (@reqGroupName varchar (255)
)
RETURNS TABLE
AS RETURN (SELECT DISTINCT UM_Groups_T.ID
FROM UM_Groups_T
WHERE (UM_Groups_T.Name=@reqGroupName))

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
*******************************************************

The C++ code (that worked for Access), reads as follows,

_CommandPtr ptrCmd(__uuidof(Command)) ;
_RecordsetPtr ptrRS(__uuidof(Recordset)) ;

ptrCmd->PutRefActiveConnection(m_ptrConn) ;

// specify stored procedure
// szQuery is the name of the stored procedure
ptrCmd->PutCommandText(szQuery) ;
ptrCmd->PutCommandType(adCmdStoredProc) ;

// have 1 parameter: ObjName
_ParameterPtr ptrParameter ;

ptrParameter = ptrCmd->CreateParameter("",adChar,adParamInput,strlen(szObj),szObj) ;
ptrCmd->GetParameters()->Append(ptrParameter) ;

ptrRS->Open((_Command*ptrCmd,vtMissing,adOpenForwardOnly,adLockOptimistic,adCmdStoredProc) ;

***********************************************************
When I run this, I get a DB_E_ERRORSOCCURRED.

Does anyone know what this might mean?
 
More info:
This is the error message:

com error: -2147217887 Msg: IDispatch error #3105 Description: Les propriétés requises ne peuvent être prises en charge.

Sorry, the string is in French, but maybe the ID will help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top