T TYZhang Unregistered / Unconfirmed GUEST, unregistred user! 2001-05-30 #2 如果要将音频文件作为字段存入数据库中,可以开辟文件流,打开音频文件,然后 将文件流赋值给字段的二进制内存流就可以保存啦。
A agang_yao Unregistered / Unconfirmed GUEST, unregistred user! 2001-05-30 #3 var S: TStream; D: TFileStream; begin Table1.Insert; D := TFileStream.Create(FileName, fmOpenRead); S := Table1.CreateBlobStream(Table1.FieldByName('DATA'), bmWrite); S.CopyFrom(D, 0); Table1.Post; D.Free; S.Free; end;
var S: TStream; D: TFileStream; begin Table1.Insert; D := TFileStream.Create(FileName, fmOpenRead); S := Table1.CreateBlobStream(Table1.FieldByName('DATA'), bmWrite); S.CopyFrom(D, 0); Table1.Post; D.Free; S.Free; end;
李 李维宏 Unregistered / Unconfirmed GUEST, unregistred user! 2001-05-30 #4 to agang_yao 我测试时程序说我的字段找不到,但肯定有此字段!WHY???
A agang_yao Unregistered / Unconfirmed GUEST, unregistred user! 2001-05-31 #5 我这没这问题,用的是什么数据库?再检查一下程序吧。 简单点的方法: Table1.Insert; TBlobField(Table1.FieldByName('DATA')).LoadFromFile(FileName); Table1.Post;
我这没这问题,用的是什么数据库?再检查一下程序吧。 简单点的方法: Table1.Insert; TBlobField(Table1.FieldByName('DATA')).LoadFromFile(FileName); Table1.Post;
肥 肥涛 Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-08 #7 如果是用SQL SERVER 7, 如何? 如果这个声音文件巨大,如何定义字段的类型及长度?
W watter Unregistered / Unconfirmed GUEST, unregistred user! 2001-08-26 #8 在sql server中,二进制类型的数据要保存到image类型的字段中。如:图片、word文档、语音、视频等
O oceanwave Unregistered / Unconfirmed GUEST, unregistred user! 2001-08-26 #9 建议看看李维的《ADO/MTS/COM+》那本书,第3章有仔细介绍:)
S sword_liu Unregistered / Unconfirmed GUEST, unregistred user! 2001-10-31 #12 我觉得,用路径要好些,不会影响server的资源。
T terry_lzs Unregistered / Unconfirmed GUEST, unregistred user! 2001-10-31 #13 procedure TForm1.Button1Click(Sender: TObject);//存储 var str:Tmemorystream; begin str:=Tmemorystream.Create; Str.LoadFromFile('C:/a.wav'); str.Position:=0; adoquery1.Append; Tblobfield(adoquery1.FieldByName('Wav')).loadfromstream(str); try adoquery1.Post; finally str.Free; end; end; procedure TForm1.Button2Click(Sender: TObject);//读出 var str:Tmemorystream; begin str:=Tmemorystream.Create; str.Position:=0; Tblobfield(adoquery1.FieldByName('Wav')).savetostream(str); str.SaveToFile('F:/gg.wav'); str.Free; end;
procedure TForm1.Button1Click(Sender: TObject);//存储 var str:Tmemorystream; begin str:=Tmemorystream.Create; Str.LoadFromFile('C:/a.wav'); str.Position:=0; adoquery1.Append; Tblobfield(adoquery1.FieldByName('Wav')).loadfromstream(str); try adoquery1.Post; finally str.Free; end; end; procedure TForm1.Button2Click(Sender: TObject);//读出 var str:Tmemorystream; begin str:=Tmemorystream.Create; str.Position:=0; Tblobfield(adoquery1.FieldByName('Wav')).savetostream(str); str.SaveToFile('F:/gg.wav'); str.Free; end;
B bobgates Unregistered / Unconfirmed GUEST, unregistred user! 2001-11-02 #14 用路径还是用binary保存都有各自的好处,看自己的需求啦