i am trying to execute a stored procedure on a local MS SQL Server instance, but it seems that i am not able to set the SP parameter.
On the ExecProc line i got this exception:
Code: Select all
Project Project1.exe raised exception class EOleException with message 'Procedure or function 'xp_addtest' expects parameter '@name', which was not supplied'.
EDIT: Using Delphi XE2 and Zeos 7.0.0.0
Table Script:
Code: Select all
CREATE TABLE [dbo].[TestTable](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) NULL
)
GO
Code: Select all
CREATE PROCEDURE [dbo].[xp_addtest](@name as varchar(50))
AS
INSERT INTO TestTable (Name) VALUES (@name)
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
conn: TZConnection;
xsp: TZStoredProc;
param: TParam;
begin
conn := TZConnection.Create(Self);
conn.Protocol := 'ado';
conn.Database :=
'Provider=SQLOLEDB.1;Password=TEST;Persist Security Info=True;User ID=LOGTest;Initial Catalog=TestDB;Data Source=.\';
conn.Connect;
xsp := TZStoredProc.Create(Self);
xsp.Connection := conn;
//xsp.StoredProcName := '';
xsp.StoredProcName := 'xp_addtest';
param := xsp.Params.CreateParam(ftString, '@name', ptInputOutput);
param.Size := 50;
param.AsString := 'AAAAAAAAA';
xsp.ExecProc;
conn.Disconnect;
end;