我的这段代码执行时出错:
var ww:TMemoryStream;
begin
with ADOCommand1 do
begin
ww:=TMemoryStream.Create;
Image1.Picture.Graphic.SaveToStream(ww);
commandtext:='insert into table1 values(qq=:pp)';
CommandType:=cmdText;
Parameters.ParamByName('pp').LoadFromStream(ww,Parameters.ParamByName('pp').DataType);
Execute;
end;
end;错误提示:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleException with message '[Microsoft][ODBC SQL Server Driver]String data, right truncation'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
var ww:TMemoryStream;
begin
with ADOCommand1 do
begin
ww:=TMemoryStream.Create;
Image1.Picture.Graphic.SaveToStream(ww);
commandtext:='insert into table1 values(qq=:pp)';
CommandType:=cmdText;
Parameters.ParamByName('pp').LoadFromStream(ww,Parameters.ParamByName('pp').DataType);
Execute;
end;
end;错误提示:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleException with message '[Microsoft][ODBC SQL Server Driver]String data, right truncation'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
我用的Query\Table将其中的image型字段与DbImage控件相连
用DbImage控件的
Picture.LoadFromFile(FileName);//读取文件
用DbImage控件的
Picture.SaveToClipboardFormat(AFormat,AData,APalette);
Picture.LoadFromClipboardFormat(AFormat,AData,APalette);
转换为二进制文件并写入内存
用post提交
以上可是我一下午才琢磨出来的存储图片源代码
更改如下:
ww.Position:=0;
Parameters.ParamByName('pp').LoadFromStream(ww,ftGraphic);