Hi All,
I have created a report in visual studio with two static datasources on it for testing purposes while in development to ensure that the report shows the data correctly. I have two one for the main report and then there is a table on the report which has another datasource. If i preview the report everything works as i would expect. I then have the following code to create the form and assign the datasources dynamically at runtime so that i can select the correct data from the mysql database based on users input.
Dim
ReportViewer
As
New
RadfrmReportViewer
Dim
NotificationReport
As
New
rptDCN
Dim
strMainDataCommand
As
String
=
"SELECT * FROM tbldcns WHERE dcn_id = '"
& lstDCNs.SelectedItem.Tag &
"';"
Dim
strPartsDataCommand
As
String
=
"SELECT part_name FROM tbldcn_inc_prts WHERE dcn_id = '"
& lstDCNs.SelectedItem.Tag &
"';"
Dim
mysqlReportMainDataSource
As
New
SqlDataSource(strMainDataCommand, strDBConnectionString)
Dim
mysqlReportPartsDataSource
As
New
SqlDataSource(strPartsDataCommand, strDBConnectionString)
NotificationReport.DataSource = mysqlReportMainDataSource
NotificationReport.rpttblParts.DataSource = mysqlReportPartsDataSource
NotificationReport.txtFooter.Value =
"Printed on {Now()} By "
& System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Replace(Environment.UserName,
"."
,
" "
))
Dim
DisplayReport
As
New
InstanceReportSource
DisplayReport.ReportDocument = NotificationReport
ReportViewer.ReportViewer1.ReportSource = DisplayReport
ReportViewer.ReportViewer1.ZoomMode = Telerik.ReportViewer.WinForms.ZoomMode.FullPage
ReportViewer.ReportViewer1.RefreshReport()
ReportViewer.Show()
However when i now run the application and run the code i am getting the error that's attached.
I have double checked the SQL strings and the connection string including copying and pasting them exactly into the static data sources and its still not working. I'm sure that i am doing something wrong but i can't see what at all. Please can someone assist me with this.
Also the strDBConnectionString variable is also used in several other locations including to populate a listcontrol which allows the user to select the item they wish to generate the report for and that is all working as expected.
I have also double checked the SQL and connection strings at runtime to ensure that they are populating correctly.
Thanks in advanced
Luke