Wednesday, March 28, 2012

reportviewer blues

Hi,

Just trying to get my had around reportviewer in MS Visual Web Dev 2005. All is well if I do it all with the wizards etc but I want to be able to filter data based on textboxs etc and can't seem to do that without code. So I have started looking at coding it and have the following so far (I realise this will not filter on textbox data but I think I can get there from here if I get it working).

Imports Microsoft.Reporting.WebForms

Imports System.Data

Imports System.Data.SqlClient

PartialClass _Default

Inherits System.Web.UI.Page

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

'Set the processing mode for the ReportViewer to Local

ReportViewer1.ProcessingMode = ProcessingMode.Local

Dim repAs LocalReport = ReportViewer1.LocalReport

rep.ReportPath ="SalesReport.rdlc"

Dim dsAs DataSet = GetSalesData()

'Create a report data source for the sales order data

Dim dsSalesOrderAsNew ReportDataSource()

dsSalesOrder.Name ="SalesData_Data"

dsSalesOrder.Value = ds.Tables("SalesData")

rep.DataSources.Add(dsSalesOrder)

EndSub

PrivateFunction GetSalesData()

Dim dsAsNew DataSet

Dim SQLConAsNew SqlConnection("SERVER= .\sqlexpress;Database=Adventureworks; Integrated Security=true;")

Dim commandAsNew SqlCommand("SELECT SalesPersonID, CountryRegionName FROM [AdventureWorks].[Sales].[vSalesPerson] WHERE CountryRegionName = 'Canada'", SQLCon)

Dim salesOrderAdapterAsNew SqlDataAdapter(command)

salesOrderAdapter.Fill(ds,"SalesData")

salesOrderAdapter.Dispose()

command.Dispose()

Return ds

EndFunction

EndClass

_____________________________________________________________________________________________

When I run it I get the following error

A data source instance has not been supplied for the data source 'Salesdata_vSalesPerson'

Any help appriciated

Thanks

Zuma

I can't beleive no one knows the answer to this one. Please help :(|||

Zuma:

When I run it I get the following error

A data source instance has not been supplied for the data source 'Salesdata_vSalesPerson'

modify this line

dsSalesOrder.Name ="SalesData_Data"

to be

dsSalesOrder.Name ="Salesdata_vSalesPerson"

|||

Thanks anooor, that was. I appriciate your time and skill.

No comments:

Post a Comment