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?
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?