Home > Back-end >  C builder how to TXT file saved to sqlserver2008 database?
C builder how to TXT file saved to sqlserver2008 database?

Time:09-23

Using text type database field directly?

CodePudding user response:

Database field with TBlob type

CodePudding user response:

Any file can save in binary stream to BlobField fields,

CodePudding user response:

 
//insert
Void __fastcall TfrmMain: : btn11Click (TObject * Sender)
{
TMemoryStream * pMS=new TMemoryStream;
Qry1 - & gt; Close ();
Qry1 - & gt; SQL - & gt; The Clear ();
String SQL="insert into information (text) values (: text)";
Qry1 - & gt; SQL - & gt; Add (SQL);
Mmo1 - & gt; Lines - & gt; SaveToStream (pMS);
PMS - & gt; The Position=0;
Qry1 - & gt; The Parameters - & gt; ParamByName (" text ") - & gt; LoadFromStream (pMS, ftBlob);
Qry1 - & gt; ExecSQL ();
Qry1 - & gt; Close ();
Delete the pMS.
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

Refer to the right, ha ha
http://blog.csdn.net/xjq2003/article/details/3898634
  • Related