Generating Reports Using VB.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zxc

    #1

    Generating Reports Using VB.net

    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

  • tommaso.gastaldi@uniroma1.it

    #2
    Re: Generating Reports Using VB.net

    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:
    [color=blue]
    > 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[/color]

    Comment

    • zxc

      #3
      Re: Generating Reports Using VB.net

      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("W ord.Application ")
      oWord.Visible = True
      oWord.Activate( )
      'Create a new document.
      oWord.Documents .Add()
      Dim connStr As String = "workstatio n id='DEV-INTERN';packet
      size=4096;integ rated security=SSPI;d ata source='DEV-INTERN';persist
      security info=False;init ial catalog=pubs"
      Dim myconnection As New SqlClient.SqlCo nnection(connSt r)
      Dim query As String = "SELECT emp_id, minit, lname, fname FROM
      employee"
      Dim mycommand As SqlClient.SqlCo mmand = New
      SqlClient.SqlCo mmand
      Dim rng As Word.Range = oWord.ActiveDoc ument.Range(sta rt:=0, End:=0)
      rng.Text = query
      End Sub

      Comment

      • tommaso.gastaldi@uniroma1.it

        #4
        Re: Generating Reports Using VB.net

        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

        Comment

        Working...