Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 3rd, 2008, 05:19 PM
Registered User
 
Join Date: Dec 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Programatically Rendering a Report

I am working on an application that renders a report (.rdlc) to a user based on criteria entered. Upon clicking a button I build a paramaterized call to a SQL Stored procedure. The data is returned to a dataset and I use that dataset to propulate a report. The problem is I can see data in the dataset/datatable, and the report looks like it is being initialized/filled with the retreved data but it does not render the report in teh reportviewer. Here is the .XSD:

(I had to shortcut the url in the schema due to forum issues. It sthe standard namespace stuff.)

<?xml version="1.0"?>
<xs:schema id="ReportData" xmlns="" xmlns:xs="XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="ReportData" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="ReportRecords">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="UserID" msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
              <xs:element name="EmployeeName" msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
              <xs:element name="WorkTeam" msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
              <xs:element name="ManagerName" msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
              <xs:element name="ProjectID" msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
              <xs:element name="ProjectName" msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
              <xs:element name="Hours" type="xs:decimal" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

And the report was generated using a wizard from this xsd.

Here is the code called after the button is clicked:

Sub GetData2()

        'step 1. get the data using a stored procedure and store to a dataset
        Dim connectionString As String = System.Configuration.ConfigurationManager.Connecti onStrings("appConnectionString").ConnectionString
        Dim myConnection As SqlConnection = New SqlConnection(connectionString)
        Dim myCommand As SqlCommand = New SqlCommand("dbo.usp_GetMangersReportData", myConnection)
        Dim myDataSet As DataSet = New DataSet()
        Dim myStartDate As DateTime = txtStartDate.Text
        Dim myEndDate As DateTime = txtEndDate.Text
        Dim mySelectedValue As String = DropDownListWorkTeam.SelectedItem.Text

        If mySelectedValue = "" Then
            mySelectedValue = " "
        End If
        myCommand.Parameters.Clear()
        myCommand.CommandType = Data.CommandType.StoredProcedure

        'supply the parameters
        With myCommand
            .CommandType = CommandType.StoredProcedure
            .Parameters.Add("@StartDate", SqlDbType.VarChar, 12)
            .Parameters("@StartDate").Value = myStartDate.ToString("yyyy-MM-dd")
            .Parameters.Add("@EndDate", SqlDbType.VarChar, 12)
            .Parameters("@EndDate").Value = myEndDate.ToString("yyyy-MM-dd")
            .Parameters.Add("@WorkTeam", SqlDbType.VarChar, 100)
            .Parameters("@WorkTeam").Value = mySelectedValue
            .Parameters.Add("@ManagerId", SqlDbType.Int)
            .Parameters("@ManagerId").Value = DropDownListManager.SelectedValue
            .Parameters.Add("@EmployeeId", SqlDbType.Int)
            .Parameters("@EmployeeId").Value = DropDownListEmployee.SelectedValue
        End With

        Dim myadapter As New SqlDataAdapter(myCommand)
        Dim myDataTable As DataTable = New DataTable("ReportRecords")

        'define the table columns
        Dim column As DataColumn

        ' Create new DataColumn, set DataType, ColumnName
        ' and add to DataTable.
        column = New DataColumn()
        With column
            .DataType = System.Type.GetType("System.Int32")
            .ColumnName = "UserID"
            .ReadOnly = True
            .Unique = False
        End With

        ' Add the Column to the DataColumnCollection.
        myDataTable.Columns.Add(column)

        ' Create new DataColumn, set DataType, ColumnName
        ' and add to DataTable.
        column = New DataColumn()
        With column
            .DataType = System.Type.GetType("System.String")
            .ColumnName = "EmployeeName"
            .ReadOnly = True
            .Unique = False
        End With

        ' Add the Column to the DataColumnCollection.
        myDataTable.Columns.Add(column)

        ' Create new DataColumn, set DataType, ColumnName
        ' and add to DataTable.
        column = New DataColumn()
        With column
            .DataType = System.Type.GetType("System.String")
            .ColumnName = "WorkTeam"
            .ReadOnly = True
            .Unique = False
        End With

        ' Add the Column to the DataColumnCollection.
        myDataTable.Columns.Add(column)

        ' Create new DataColumn, set DataType, ColumnName
        ' and add to DataTable.
        column = New DataColumn()
        With column
            .DataType = System.Type.GetType("System.String")
            .ColumnName = "ManagerName"
            .ReadOnly = True
            .Unique = False
        End With

        ' Add the Column to the DataColumnCollection.
        myDataTable.Columns.Add(column)

        ' Create new DataColumn, set DataType, ColumnName
        ' and add to DataTable.
        column = New DataColumn()
        With column
            .DataType = System.Type.GetType("System.Int32")
            .ColumnName = "ProjectID"
            .ReadOnly = True
            .Unique = False
        End With

        ' Add the Column to the DataColumnCollection.
        myDataTable.Columns.Add(column)

        ' Create new DataColumn, set DataType, ColumnName
        ' and add to DataTable.
        column = New DataColumn()
        With column
            .DataType = System.Type.GetType("System.String")
            .ColumnName = "ProjectName"
            .ReadOnly = True
            .Unique = False
        End With

        ' Add the Column to the DataColumnCollection.
        myDataTable.Columns.Add(column)

        ' Create new DataColumn, set DataType, ColumnName
        ' and add to DataTable.
        column = New DataColumn()
        With column
            .DataType = System.Type.GetType("System.Decimal")
            .ColumnName = "Hours"
            .ReadOnly = True
            .Unique = False
        End With

        myConnection.Open()

        myadapter.Fill(myDataTable)

        'add our table to the dataset
        myDataSet.Tables.Add(myDataTable)

        'name the dataset for later
        myDataSet.DataSetName = "ReportData"

        'step 2. move data from dataset to the report xsd file

        'The path to the RDLC (report layout and binding description). This is
        'set to be copied locally with the app (ClickOnce required), so we can use
        'the app run location as the path.
        With ReportViewer1
            .ProcessingMode = ProcessingMode.Local
            'the datasource names match the .xsd file node names
            .LocalReport.DataSources.Add(New ReportDataSource("ReportData", myDataSet.Tables("ReportRecords")))
            .LocalReport.ReportPath = System.AppDomain.CurrentDomain.BaseDirectory & "rptManagersReport.rdlc"

            .Visible = True
            .LocalReport.ExecuteReportInCurrentAppDomain(Syste m.Reflection.Assembly.GetExecutingAssembly().Evide nce)
            .LocalReport.Refresh()
        End With

        myConnection.Close()
    End Sub

Any ideas? I am at a loss.

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rendering report from .NET roy_mm Reporting Services 0 September 13th, 2008 10:18 AM
Export Crystal Report Programatically Harinder.Dhamija ASP.NET 2.0 Basics 0 July 20th, 2007 08:28 AM
report rendering WelshAllBlack BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 November 15th, 2005 03:08 AM
Report based on query programatically nabrown78 Access VBA 2 March 22nd, 2005 08:57 PM
error in excel report rendering. hemantkanchan BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 January 5th, 2005 02:49 AM



All times are GMT -4. The time now is 06:58 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.