T0masz
asked on
adoquery (mysql) and inserting blob from file
I found this online but i cant get ParamByName to work...
I basicly want to load a file into blob (in mysql)
SQL.Add('insert into zbClientCommImg ');
SQL.Add('(CallCtr, ImgSubj, ImgUploadDT, ImgFileName, CommImg) ');
SQL.Add('VALUES(:VarCID, :VarSubj, :VarDT, :VarFileName, :VarBLOB)');
ParamByName('VarCID').AsIn teger := nCallID;
ParamByName('VarSubj').AsS tring := sSubject;
ParamByName('VarDT').AsDat e := Date;
ParamByName('VarFileName') .AsString := ExtractFileName(sFileName) ;
ParamByName('VarBLOB').Loa dFromFile( sFileName, ftBlob);
Thanks
Tom
I basicly want to load a file into blob (in mysql)
SQL.Add('insert into zbClientCommImg ');
SQL.Add('(CallCtr, ImgSubj, ImgUploadDT, ImgFileName, CommImg) ');
SQL.Add('VALUES(:VarCID, :VarSubj, :VarDT, :VarFileName, :VarBLOB)');
ParamByName('VarCID').AsIn
ParamByName('VarSubj').AsS
ParamByName('VarDT').AsDat
ParamByName('VarFileName')
ParamByName('VarBLOB').Loa
Thanks
Tom
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mnasman you are right, I forgot about the Parameters, but I think it will work: Parameters.ParamByName('Va rCID').VAL UE
with ADOQuery1.Parameters do
begin
ParamByName('VarCID').Valu e := nCallID;
ParamByName('VarSubj').Val ue := sSubject;
ParamByName('VarDT').Value := TDateTime(Date); // or TDate(Date); it depends on the field's type declaration
ParamByName('VarFileName') .Value := ExtractFileName(sFileName) ;
TBLOBField(ParamByName('Va rBLOB')).L oadFromFil e(sFileNam e, ftBlob);
end;
with ADOQuery1.Parameters do
begin
ParamByName('VarCID').Valu
ParamByName('VarSubj').Val
ParamByName('VarDT').Value
ParamByName('VarFileName')
TBLOBField(ParamByName('Va
end;
esoftbg , you are right
But there's no need to type casting the parameter to TBLobField, and if you do so, it will require one argument only
with ADOQuery1.Parameters do
begin
ParamByName('VarCID').Valu e := nCallID;
ParamByName('VarSubj').Val ue := sSubject;
ParamByName('VarDT').Value := TDateTime(Date);
ParamByName('VarFileName') .Value := ExtractFileName(sFileName) ;
ParamByName('VarBLOB').Loa dFromFile( sFileName, ftBlob);
end;
But there's no need to type casting the parameter to TBLobField, and if you do so, it will require one argument only
with ADOQuery1.Parameters do
begin
ParamByName('VarCID').Valu
ParamByName('VarSubj').Val
ParamByName('VarDT').Value
ParamByName('VarFileName')
ParamByName('VarBLOB').Loa
end;
Thanks mnasman !
I think you are using AdoQuery, so ParamByName method is part of Parameters property so use this for using parameters
Parameters.ParamByName('Va
Regards,
Mohammed