473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

display data from database in ms.word?

Hi,
my requriment is i want to display data from database in ms.word? Iam using asp.net with C#
bcoz iam inserting resume in sqlserver, so i want to display that resume in word
Apr 15 '08 #1
1 1680
Curtis Rutland
3,256 Expert 2GB
Hi,
my requriment is i want to display data from database in ms.word? Iam using asp.net with C#
bcoz iam inserting resume in sqlserver, so i want to display that resume in word
This is a fun one. You need to add a reference to Microsoft.Office.Interop.Word. You can do this by clicking Website-->Add Reference from the menu bar. Make sure you are on the .NET tab and scroll to find Microsoft.Office.Interop.Word and click ok.

This should tell you more, but here's a quick start:
Expand|Select|Wrap|Line Numbers
  1. //c# code
  2. object filename = @"c:\temp.doc";
  3. FileStream fs = new FileStream((string)filename, FileMode.OpenOrCreate, FileAccess.ReadWrite);
  4. fs.Close();
  5. object missing = System.Reflection.Missing.Value;
  6. Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
  7. Microsoft.Office.Interop.Word.Document doc = null;
  8. DateTime today = DateTime.Now;
  9. object readOnly = false;
  10. object isVisible = false;
  11. doc = wordApp.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
  12. doc.Activate();
  13. doc.Content.InsertAfter("Text");
  14. doc.Save();
  15. wordApp.Visible = true;
  16.  
Line 13 is where the writing to the document happens. So, if you have already gotten all your data from the database, here is where you can write it.
Have fun.
Apr 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dmiller23462 | last post by:
Somebody take a look and give me any suggestions? My brain is nuked... Here's my deal....I have online submission forms on my intranet at work here....I am appending to an Access DB with the...
3
by: Chumley the Walrus | last post by:
IN my code behind .vb page for a delete records script (this also does a deletion confirmation with a javascript popup, this gets called on my front .aspx page with the datagrid), I'm not sure if...
3
by: intl04 | last post by:
Is it possible to create a Word form as the data entry form for an Access database? I didn't see any reference to this possibility in my Access books, so I'm sorry if this is a question that is...
0
by: Steve | last post by:
I'm using a ListView control in conjunction with a TreeView control to display SqlServer database records. Clicking a Node in the TreeView refreshes the ListView with the content of the associated...
1
by: tfs | last post by:
I have a word file stored in an SQL database and am trying to read and display on my ASP.Net page. It seems to work OK as far as reading and displaying on the page, but it is not displaying as a...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
2
by: magix | last post by:
Hi, I'm using Access Database with ASP. There is one particular thing that I have issue with. My purpose is for user to update their own profile. Their existing profile information will be...
2
by: =?Utf-8?B?c2NvdHRybQ==?= | last post by:
Hi I am using a SQL Server 2005 varbinary(max) to store word documents in the database. I can retrive the data out into a MemoryStream object ok but I want to be able to use this to display the...
4
by: shelley_2000 | last post by:
What is the best approach to collect and load Employee Resume Data from External Employees who may not have Microsoft access? If is likely they will have Microsoft Word, but not Microsoft Access. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.