Page 1 of 1
Stored Procedure & Image
Posted: Sat 10 Nov 2007 16:22
by hmelihkara
Is there any way that i can post image with a stored procedure?
MSDN said "images can't be post by sps caused by limitations"!
Posted: Mon 12 Nov 2007 09:54
by Antaeus
You can do it by executing commands like the one below through TMSQuery/TMSCommand conmonents.
Code: Select all
{:EmpNO = CALL SDAC_InsertEmp;1(:ENAME, :JOB, :IMG)}
Before executing load an image into the parameter:
Code: Select all
Params.ParamByName('img').LoadFromFile(ImagePath, ftBlob);
Another way is TMSStoredProc component:
Code: Select all
MSStoredProc1.StoredProcName := 'SDAC_InsertEmp';
MSStoredProc1.Params.ParamByName('ENAME').AsString := 'AName';
MSStoredProc1.Params.ParamByName('Job').AsString := 'AJob';
MSStoredProc1.Params.ParamByName('img').LoadFromFile(ImagePath, ftBlob);
MSStoredProc1.Execute;
The procedure is defined in this way:
Code: Select all
PROCEDURE [dbo].[SDAC_InsertEmp]
@ENAME nvarchar(20),
@JOB nvarchar(10),
@img image
AS
INSERT INTO
EMP (ENAME, JOB, img)
VALUES
(@ENAME, @JOB, @img)
RETURN @@Identity;