delphi 硬盘上的图片,存到oracle里的blob里 

解决方案 »

  1.   

    create table test1(a blob);ADOConnection1.ConnectionString:='Provider=OraOLEDB.Oracle.1;Password=synjones;Persist Security Info=True;User ID=user;Data Source=orcl';
    .....
    with ADODataSet1 do
    begin
      Close;
      CommandText:='select * from test1';
      Open;
      Append;
      TBlobField(FieldByName('a')).LoadFromFile('c:\123.jpg');
      Post;
    end;SQL> select count(*) from test1;  COUNT(*)
    ----------
             1SQL> 
      

  2.   

    谢谢,楼上的。按上面的方法试过了可以。不过 with adocmd do
      begin
        CommandText:='select * from TBL_XTPZ';
        Execute;
        commandtext := 'INSERT INTO TBL_XTPZ '
                     + '(XTPZ_YWMK, XTPZ_KEY, XTPZ_VALUE, XTPZ_Image, Image_Update)'
                     + ' VALUES '
                     + '(:ywmk, :key, :value, :XTPZ_Image, :Image_Update)';
        with Parameters do
        begin
          ParamByName('ywmk').value := 'ywmk110';
          ParamByName('key').Value  := 'M888';
          ParamByName('value').Value:= 'M888';
          ParamByName('XTPZ_Image').LoadFromFile('D:\Login.jpg',ftBlob);//(stream,ftOraBlob)//ftBlob) EMPTY_BLOB
          ParamByName('Image_Update').Value:= 1;
        end;
         Execute;
      end;  以上不能提写入成功啊
      

  3.   

    create table TEST1
    (
      A BLOB,
      B VARCHAR2(100)
    )
    with AdoCommand1 do
    begin
      CommandText:='insert into test1 values(:a,:b)';
      Parameters.ParamByName('a').LoadFromFile('c:\123.jpg',ftBlob);
      Parameters.ParamByName('b').Value:='123';
      Execute;
    end;SQL> select count(*) from test1;  COUNT(*)
    ----------
             1SQL>
      

  4.   

    可以了,不过
          stream:= TMemoryStream.Create;
          stream.Position:=0;
    Parameters.ParamByName('a').LoadFromStream(stream,ftBlob)
    写入空值怎么办