用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;

解决方案 »

  1.   

    //Bitmap File
    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;
      

  2.   

    //Bitmap File
    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;
      

  3.   

    //Bitmap File
    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;
      

  4.   

    同意 Carfield(一只特别懒的猫)
      

  5.   

    我想要一个完整的程序,是否有人能够提供
    [email protected]
      

  6.   


    看帮助!
    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;