How the Word document into SQL Sever database?

Category: C/C++ -> Database Author: dndng Date: 2001-07-26 10:44:41
 
dndng
2001-07-26 10:44:41
In C + + Builder 6 how to write a program stored in a Word document SQL Sever database? How to SQL Sever database into a Word document to read and displayed, heroes who help, 100 hands.
yangliSkyhero
2001-07-26 10:51:45
TBlobField :: LoadFromFile
TBlobField :: SaveToFile
jngyh
2001-07-26 11:10:29
Upstairs heroes, will give an example of usage Oh, thank you
tlwxs
2001-07-26 11:24:47
You can use the following method: Save the file name
AnsiString filename = DBEdit3-> Text;
AQ_ProjectDrawManage-> Edit () ;
AQ_ProjectDrawManageGRAPHIC-> LoadFromFile (DBEdit3-> Text.c_str ());
if (DBEdit1 -> Text == "")
{
; ShowMessage ("the complete information is not complete!");
}

else
{
AQ_ProjectDrawManage-> Refresh ();
;}

then read
if (AQ_ProjectDrawManage-> FieldByName ("Graphic")! = NULL)
{
AnsiString fName = AQ_ProjectDrawManage-> FieldByName ("DrawingName") -> ; AsString;
AnsiString path = ExtractFileDir (Application-> ExeName) + "\ \" ; + fName;
AQ_ProjectDrawManageGRAPHIC-> SaveToFile (path);

; if (RightStr (fName, 3) == "doc")
; {
HWND handle;
handle = FindWindow (NULL, "Word - [fName.c_str ()]");
; ShellExecute (handle, "open", path.c_str (), NULL, NULL, SW_SHOWNORMAL) ;
}

else if (RightStr (fName, 3) == "dwg")
{
; HWND handle;
; handle = FindWindow (NULL, "AutoCAD - [fName.c_str ()]");
ShellExecute (handle, "open", path.c_str (), NULL, NULL, SW_SHOWNORMAL);
}

else
{
ShellExecute (NULL, "open", path. c_str (), NULL, NULL, SW_SHOWNORMAL);
}
}
dean10
2001-07-26 11:32:44
WORD document will be stored in the database:
void __ fastcall TForm1 :: Button4Click (TObject * Sender)
{
if (OpenDialog1-> Execute ())
{
TMemoryStream * Str = new TMemoryStream ();
Str-> LoadFromFile (OpenDialog1-> FileName);
Str-> Position = 0;
Query1-> Close ( );
Query1-> SQL-> Add ("insert into wordtable values ​​(: wordfile)");
; / / Query1-> ParamByName ("wordfile") -> DataType = ftBlob;
/ / Query1-> ParamByName ("wordfile" ) -> ParamType = ptInput;
Query1-> ParamByName ("wordfile") -> LoadFromStream (Str, ftBlob);

; Query1-> ExecSQL ();

delete Str;
}
}

WORD document out of the database:
void __ fastcall TForm1 :: Button6Click (TObject * Sender)
{
TMemoryStream * Str1;

ADOQuery1-> Close ();
ADOQuery1-> SQL-> Add ("select top 1 wordfile from wordtable ");
ADOQuery1-> Open ();

ADOQuery1- > Edit ();
Str1 = (TMemoryStream *) ADOQuery1-> CreateBlobStream (ADOQuery1-> FieldByName ("wordfile"),
bmReadWrite);

Str1-> SaveToFile ("c: \ \ test.doc");
delete Str1;
}
diaosky
2001-07-26 11:50:31
look at your other question: