用TADOQuery
SQL:Insert Into ...set ... Picture = :NewPic;var
vtData:OleVariant;
PtrData:PByte;
Stream:TStream;
DataSize:Integer;
begin
Stream := TFileStream.Create('e:\pics\1.bmp',fmOpenRead);
DataSize := Stream.Size;
vtData := VarArrayCreate([0,DataSize-1],varByte);
PtrData := VarArrayLock(vtData);
Stream.Position := 0;
Stream.Read(PtrData^,DataSize);
Stream.Free;
VarArrayOnlock(vtData);
ADOQuery1.Parameters.ParamByName('NewPic').Value := vtData;
vtData := Unassigned;
...//设置其它参数
ADOQuery.ExecSQL;
end;
SQL:Insert Into ...set ... Picture = :NewPic;var
vtData:OleVariant;
PtrData:PByte;
Stream:TStream;
DataSize:Integer;
begin
Stream := TFileStream.Create('e:\pics\1.bmp',fmOpenRead);
DataSize := Stream.Size;
vtData := VarArrayCreate([0,DataSize-1],varByte);
PtrData := VarArrayLock(vtData);
Stream.Position := 0;
Stream.Read(PtrData^,DataSize);
Stream.Free;
VarArrayOnlock(vtData);
ADOQuery1.Parameters.ParamByName('NewPic').Value := vtData;
vtData := Unassigned;
...//设置其它参数
ADOQuery.ExecSQL;
end;
解决方案 »
- 正则安装找不到pcrelib.dll
- delphi 高手帮忙!帮我看看这个控件怎么用?
- 请问 如何 用代码 释放 某一个控件 对鼠标的捕捉 ?????????????
- 请教,如何和Excel联系?
- 求Rational Rose 2002 for Delphi的插件
- 各位谢谢帮我把代码改成delphi好吗?
- 请高手来看看!
- 将一个空字符串付给变体类型,变体类型的值是什么。
- 版本控制VSS有那位有完整的下载地址,谢谢了
- delphi怎么调用外部其他可执行文件?
- 大家在做三层结构时,当客户端调用服务器端的某个接口的某个方法时,服务器能否识别出具体是哪个客户端在访问该接口的该方法吗?
- 我作了一個數據庫查詢語句﹐但是運行後在Open語句處出現這種錯誤‘Invalid use of Keyword.Token Date',請問如何解決﹖
with ADOTable1 do
begin
Open;
Append;
if OpenPictureDialog1.Excute then
TblobField(FieldByName('Image')).Loadfromfile (OpenPictureDialog1.FileName);
Post;
end;//Jpg File
Uses Jpeg
var
MyJpg:TJpegImage;
with ADOTable1 do
begin
Open;
Append;
MyJpg:=TJpegImage.Create;
try
if OpenPictureDialog1.Excute then
MyJpg.LoadFromFile(OpenPictureDialog1.FileName);
TblobField(FieldByName('Image')).Assign(MyJpg);
finally
MyJpg.Free
end;
Post;
end;
with ADOTable1 do
begin
Open;
Append;
if OpenPictureDialog1.Excute then
TblobField(FieldByName('Image')).Loadfromfile (OpenPictureDialog1.FileName);
Post;
end;//Jpg File
Uses Jpeg
var
MyJpg:TJpegImage;
with ADOTable1 do
begin
Open;
Append;
MyJpg:=TJpegImage.Create;
try
if OpenPictureDialog1.Excute then
MyJpg.LoadFromFile(OpenPictureDialog1.FileName);
TblobField(FieldByName('Image')).Assign(MyJpg);
finally
MyJpg.Free
end;
Post;
end;
with ADOTable1 do
begin
Open;
Append;
if OpenPictureDialog1.Excute then
TblobField(FieldByName('Image')).Loadfromfile (OpenPictureDialog1.FileName);
Post;
end;//Jpg File
Uses Jpeg
var
MyJpg:TJpegImage;
with ADOTable1 do
begin
Open;
Append;
MyJpg:=TJpegImage.Create;
try
if OpenPictureDialog1.Excute then
MyJpg.LoadFromFile(OpenPictureDialog1.FileName);
TblobField(FieldByName('Image')).Assign(MyJpg);
finally
MyJpg.Free
end;
Post;
end;
[email protected]
看帮助!
Loads a BLOB from a file into the field.procedure LoadFromFile(const FileName: string); DescriptionUse LoadFromFile to load the contents of a file into a BLOB field. Specify the name of the file to load into the field as the value of the FileName parameter.if not (Query.State in [dsInsert, dsEdit]) then Query1.Insert;Query1Images.LoadFromFile('c:\Windows\Waves.bmp');
Query1.Post;