首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

怎么以流的方式将文件写入数据库.

2012-02-20 
如何以流的方式将文件写入数据库..想把某些文件写入数据库中..需要的时候再调用出来..如何以流的方式存取

如何以流的方式将文件写入数据库..
想把某些文件写入数据库中..需要的时候再调用出来..

如何以流的方式存取呢?

求指点...

[解决办法]
其实就是blob字段得读写呀.

C/C++ code
void __fastcall TForm1::Button1Click(TObject *Sender){  TADOQuery *Query = new TADOQuery(Application);  Query->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExtractFilePath(Application->ExeName) + "1.mdb;";  Query->SQL->Text = "insert into  table1(ee)values('asddasd')";  Query->ExecSQL();  TMemoryStream *Inifile = new TMemoryStream();  Inifile->LoadFromFile("123.ini");  Query->SQL->Text = "update table1 set asd =:PHOTO where ee ='asddasd'" ;  Query->Parameters->Items[0]->LoadFromStream(Inifile,ftBlob) ;  Query->ExecSQL();  Query->Close();  delete Query;  delete Inifile;}//---------------------------------------void __fastcall TForm1::Button2Click(TObject *Sender){  TADOQuery *Query = new TADOQuery(Application);  Query->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExtractFilePath(Application->ExeName) + "1.mdb;";  Query->SQL->Text = "select * from table1 where ee ='asddasd'";  Query->Open();  TBlobField * pField1=(TBlobField *)Query->FieldByName("asd");     if(!pField1->IsNull)     {   TADOBlobStream* pmem=new TADOBlobStream (pField1,bmRead);   pmem->Seek(0,soFromBeginning);   TMemoryStream *Inifile = new TMemoryStream();   Inifile->LoadFromStream(pmem);   Inifile->SaveToFile("12345.ini");   delete Inifile;   delete pmem;     }  Query->Close();  delete Query;} 

热点排行