Generating Reports Using VB.net

Z

zxc

hi i want to ask how can we retrieve data from MS sql server table
northwind and generate report of same data in formated form in MS word
using VB.net ... i need its code can any one help please .. its real
urgent .. i m currently using Visual Studio 2003 ... and MS SQL server
2003
thanks in advance
 
T

tommaso.gastaldi

Hi zxc,

imvho your question to be answered fully might even require a few years
of work, unless you need a real simple output and you want to use third
part tools which incorporate those functionalities. Just the making -
from scratch - of a report engine (which could also allow crosstabs,
sections, interruptions, cell merging, alarms, conditional formatting)
is quite an effort...

-tom

zxc ha scritto:
 
Z

zxc

hi tom
thanks for replying... i need a simple output .. i m able to write hard
coded values in MS word using VB.net but i m unable to write the values
from MS SQL database ... heres my code but problem is this when i run
this program a word document opens and displays SELECT emp_id, minit,
lname, fname FROM employee
but i want there database values not this exact statement .. how can i
do it .. a little help is needed here thanks


Word = CreateObject("Word.Application")
oWord.Visible = True
oWord.Activate()
'Create a new document.
oWord.Documents.Add()
Dim connStr As String = "workstation id='DEV-INTERN';packet
size=4096;integrated security=SSPI;data source='DEV-INTERN';persist
security info=False;initial catalog=pubs"
Dim myconnection As New SqlClient.SqlConnection(connStr)
Dim query As String = "SELECT emp_id, minit, lname, fname FROM
employee"
Dim mycommand As SqlClient.SqlCommand = New
SqlClient.SqlCommand
Dim rng As Word.Range = oWord.ActiveDocument.Range(start:=0, End:=0)
rng.Text = query
End Sub
 
T

tommaso.gastaldi

Hello zxc,

sorry for delay. I have been busy on my project for few days.
If I were you I would export by using XML. It's extremely fast. Forget
about Ole, it's ridicolously slow. People would laugh at your program.

The same strategy can be used for EXCEL (whose xml is much much simpler
tha word's). Go here to study the basics:

http://blogs.msdn.com/brian_jones/

the rest you can learn by reverse eng.

Keep me update about your project I am interested in it. I have done
some massive export to Excel with XML and it is very handy and fast. I
never tried to export to word, but just for curiosity I have studied a
little its XML, and it is quite more complex than excel (because word
does more things and probably because Microsoft has put more effort in
it....)

tommaso
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top