TUniStoredProc accessing SQL Server 2005 via ODBC
Posted: Tue 14 May 2013 16:32
Hello,
I'm attempting to convert an application from the BDE to UniDac components. I'm using the trial edition to determine the issues. If it's relatively painless then we may proceed with our purchase. The conversion has been relatively painless except calling stored procedures via ODBC(SQL Native Client driver). I've been instructed to use ODBC so switching to an SQLProvider is not an option. I tried using the TUniStoredProc component with the following source but keep getting the error "[Microsoft][SQL Native Client][SQL Server]Procedure or function 'ai_nextid' expects parameter '@name', which was not supplied. Any insight to my problem?
client side delphi source code snippet:
frmDataMod1.sp1.Params.Clear;
frmDataMod1.sp1.Params.CreateParam(ftString, '@name', ptInput);
frmDataMod1.sp1.Params.CreateParam(ftInteger, '@nextid', ptInputOutput);
frmDataMod1.sp1.Params[0].AsString := 'CLIENT_ID';
frmDataMod1.sp1.Execute;
lResult := frmDataMod1.sp1.Params[1].AsInteger;
stored procedure definition:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[ai_nextid] @name VARCHAR(10), @nextid
INT OUTPUT AS UPDATE AUTOINC SET id = id+1 WHERE name = @name
SELECT @nextid = id FROM AUTOINC WHERE name = @name
Terry
I'm attempting to convert an application from the BDE to UniDac components. I'm using the trial edition to determine the issues. If it's relatively painless then we may proceed with our purchase. The conversion has been relatively painless except calling stored procedures via ODBC(SQL Native Client driver). I've been instructed to use ODBC so switching to an SQLProvider is not an option. I tried using the TUniStoredProc component with the following source but keep getting the error "[Microsoft][SQL Native Client][SQL Server]Procedure or function 'ai_nextid' expects parameter '@name', which was not supplied. Any insight to my problem?
client side delphi source code snippet:
frmDataMod1.sp1.Params.Clear;
frmDataMod1.sp1.Params.CreateParam(ftString, '@name', ptInput);
frmDataMod1.sp1.Params.CreateParam(ftInteger, '@nextid', ptInputOutput);
frmDataMod1.sp1.Params[0].AsString := 'CLIENT_ID';
frmDataMod1.sp1.Execute;
lResult := frmDataMod1.sp1.Params[1].AsInteger;
stored procedure definition:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[ai_nextid] @name VARCHAR(10), @nextid
INT OUTPUT AS UPDATE AUTOINC SET id = id+1 WHERE name = @name
SELECT @nextid = id FROM AUTOINC WHERE name = @name
Terry