saving doc file in sql database
i have developed window application , and i need to save doc file in sql database from my application. should there be binary field in database to save such files? or which datatype should i use? and how can i do that using c#.net 2005? need solution....
Lalit MPosted Nov 12, 2009, 4:07 AM
Add reference to Microsoft Office 11.0 Object Library using the Add Reference dialog box.
using Microsoft.Office.Core;
using System.Reflection;
public void CreateDoc()
{
object missing = System.Reflection.Missing.Value;
object endOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
//Start Word and create a new document.
Word._Application word = new Word.Application();
Word._Document document = word.Documents.Add(ref missing, ref missing, ref missing, ref missing);
//Insert a paragraph at the beginning of the document.
Word.Paragraph para1;
para1 = document.Content.Paragraphs.Add(ref missing);
para1.Range.Text = "Adding paragraph thru C#";
para1.Range.Font.Bold = 1;
para1.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
para1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
para1.Range.InsertParagraphAfter();
word.Visible = true;
document.Save();
document.Close(ref missing, ref missing, ref missing);
word.Quit(ref missing, ref missing, ref missing);
}
more info
Serban CosminPosted Sep 20, 2009, 1:08 PM