none
Visual Report/Viewer capability RRS feed

  • Question

  • Hello Everyone,

    I’m still working on my database tool and another issue has reared its ugly head.

    First an overview of what I am trying to accomplish. I have used Microsoft Access for many years and the tools I have always liked are the query and report designers. The query designer lets the user visually build queries and the reports designer allows the user to create a report based on that query.

    The idea behind my tool is to have both of these capabilities, but would allow the user to grab data from any available database. I have found a free visual query builder from another web page, thus solving the first requirement.

    Solving the visual report designer-viewer part of this project has become elusive. I have searched the Internet and haven’t been able to find a free .NET or COM control that comes close to what MS-Access has.  From all indications it looks like I will have to build aforementioned capability from scratch, and I have no clue where to begin.

    Does anyone know where I can download a .NET type control or at least show me where to begin if it has to be coded from scratch?

    I am trying to learn software development using the .NET framework and Visual Studio 2008 Professional and this project is my way of doing it that.

    Thanks,

    MRM256
    • Moved by Mark Liu-lxf Friday, October 19, 2012 6:10 AM (From:Visual Basic General)
    Thursday, October 18, 2012 7:15 PM

Answers

  • Hi Everyone,

    I had to at least find some way to print out varaible dataset information. The best thing I could come up with in my limited experience with VS 2008 was to use MS-Word as the receipiant of the dataset.

    This routine places the data into cells of a Word Table.

    Namespace needed:
    Imports Word = Microsoft.Office.Interop.Word
    Private Sub CreateWordDocument(ByVal dt As DataTable, _
                                       ByVal strSQL As String, _
                                       ByVal strDB As String)
            'Purpose:       Creates a tablular report from the datatable
            'Parameters:    dt As Datatable - Datatable from SQL
            'Returns:       A MS-Word document containing the DB Connection string,
            '               strSQL - Structured Query Language string
            '               strDB - Database we retrieve the information from
            Dim objWord As Word.Application
            Dim objDoc As Word.Document
            Dim objTable As Word.Table
            objWord = CreateObject("Word.Application")
            objWord.Visible = True
            objDoc = objWord.Documents.Add
            Dim r As Integer, c As Integer
            Dim NumRows As Integer, NumCols As Integer
            Dim resourcePath As String
            resourcePath = Application.StartupPath
            NumRows = dt.Rows.Count
            NumCols = dt.Columns.Count
            Try
                With objDoc
                    'Change page orientation to landscape.
                    .PageSetup.Orientation = Word.WdOrientation.wdOrientLandscape
                    'Open document header section 
                    .ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader
                    'Place database connection string into header section
                    .Range.Text = strDB
                    'Go to main document section
                    .ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument
                    'Turn on table gridlies
                    .ActiveWindow.View.TableGridlines = True
                    'Add table containing connection string and SQL used to return data
                    objTable = .Tables.Add(objDoc.Bookmarks.Item("\endofdoc").Range, 1, 1)
                    With objTable
                        'Place SQL string used to generate data into cell of table
                        .Cell(1, 1).Range.ParagraphFormat.Alignment = Word.WdAutoFitBehavior.wdAutoFitFixed
                        .Cell(1, 1).Range.Text = strSQL
                    End With
                    objDoc.Range.Paragraphs.Add()
                End With
                objTable = objDoc.Tables.Add(objDoc.Bookmarks.Item("\endofdoc").Range, NumRows, NumCols)
                With objTable
                    ' For each row, print the values of each column. 
                    Dim row As DataRow
                    r = 1
                    For Each row In dt.Rows
                        Dim column As DataColumn
                        c = 1
                        For Each column In dt.Columns
                            .Cell(r, c).Range.ParagraphFormat.Alignment = Word.WdAutoFitBehavior.wdAutoFitFixed
                            .Cell(r, c).Range.Text = row(column)
                            'Debug.Print(row(column))
                            c += 1
                        Next column
                        r += 1
                    Next row
                End With
            Catch ex As Exception
                MessageBox.Show(ex.Message, "CreatWordDocument Subroutine")
            End Try
        End Sub

    Later,

    MRM256

    • Marked as answer by MRM256 Saturday, November 3, 2012 5:39 PM
    Saturday, November 3, 2012 5:38 PM

All replies

  • Hi MRM256,

    Welcome to the MSDN forum.

    As I read you issue, it seems that the .net report control can help you cover this issue.   

    As Microsoft provides a special forum to deal with report issue, I’d like to move this thread to Visual Studio Report Controls forum. It will cost a little time to involve the members in this forum. I appreciate your patience.

    Sorry for any inconvenience and have a nice day.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    Friday, October 19, 2012 6:10 AM
  • Thanks Mark,

    I'll look for my post on the other forum.

    MRM256

    Friday, October 19, 2012 12:41 PM
  • My database tool creates datasets on the fly.

    The ReportViewer control is useless to me unless I can design new reports based on the dataset that I just created.

    How come the ReportViewer control only allows you to access the report designer while you are developing your application?

    To me it seems like you ham-strung yourself by deigning the devloper the use of the Report Designing feature.

    Thanks,

    MRM256

    Monday, October 22, 2012 4:38 PM
  • It looks like no one here can shed any light on how to include a Report Designer/Viewer capability into your own WinForms applications.

    Crystal Reports doesn't want you to have it unless you pay them $1000.00 just so you can use it in applications that are installed elsewhere.

    The Designer functions of the ReportViewer are only avalable when you are designing an application with a predetermined dataset.

    It look like VS is no longer designed to make applications that are versital, and flexible.

    MRM256

    Saturday, October 27, 2012 10:54 PM
  • Hi Everyone,

    I had to at least find some way to print out varaible dataset information. The best thing I could come up with in my limited experience with VS 2008 was to use MS-Word as the receipiant of the dataset.

    This routine places the data into cells of a Word Table.

    Namespace needed:
    Imports Word = Microsoft.Office.Interop.Word
    Private Sub CreateWordDocument(ByVal dt As DataTable, _
                                       ByVal strSQL As String, _
                                       ByVal strDB As String)
            'Purpose:       Creates a tablular report from the datatable
            'Parameters:    dt As Datatable - Datatable from SQL
            'Returns:       A MS-Word document containing the DB Connection string,
            '               strSQL - Structured Query Language string
            '               strDB - Database we retrieve the information from
            Dim objWord As Word.Application
            Dim objDoc As Word.Document
            Dim objTable As Word.Table
            objWord = CreateObject("Word.Application")
            objWord.Visible = True
            objDoc = objWord.Documents.Add
            Dim r As Integer, c As Integer
            Dim NumRows As Integer, NumCols As Integer
            Dim resourcePath As String
            resourcePath = Application.StartupPath
            NumRows = dt.Rows.Count
            NumCols = dt.Columns.Count
            Try
                With objDoc
                    'Change page orientation to landscape.
                    .PageSetup.Orientation = Word.WdOrientation.wdOrientLandscape
                    'Open document header section 
                    .ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader
                    'Place database connection string into header section
                    .Range.Text = strDB
                    'Go to main document section
                    .ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument
                    'Turn on table gridlies
                    .ActiveWindow.View.TableGridlines = True
                    'Add table containing connection string and SQL used to return data
                    objTable = .Tables.Add(objDoc.Bookmarks.Item("\endofdoc").Range, 1, 1)
                    With objTable
                        'Place SQL string used to generate data into cell of table
                        .Cell(1, 1).Range.ParagraphFormat.Alignment = Word.WdAutoFitBehavior.wdAutoFitFixed
                        .Cell(1, 1).Range.Text = strSQL
                    End With
                    objDoc.Range.Paragraphs.Add()
                End With
                objTable = objDoc.Tables.Add(objDoc.Bookmarks.Item("\endofdoc").Range, NumRows, NumCols)
                With objTable
                    ' For each row, print the values of each column. 
                    Dim row As DataRow
                    r = 1
                    For Each row In dt.Rows
                        Dim column As DataColumn
                        c = 1
                        For Each column In dt.Columns
                            .Cell(r, c).Range.ParagraphFormat.Alignment = Word.WdAutoFitBehavior.wdAutoFitFixed
                            .Cell(r, c).Range.Text = row(column)
                            'Debug.Print(row(column))
                            c += 1
                        Next column
                        r += 1
                    Next row
                End With
            Catch ex As Exception
                MessageBox.Show(ex.Message, "CreatWordDocument Subroutine")
            End Try
        End Sub

    Later,

    MRM256

    • Marked as answer by MRM256 Saturday, November 3, 2012 5:39 PM
    Saturday, November 3, 2012 5:38 PM