Joined: 27 Apr 2012
Location: United States
Online Status: Offline
Posts: 1
Topic: Subreports at run-time Posted: 27 Apr 2012 at 12:31pm
I'm programming in Visual Studio 2010/VB.Net and reporting off of SQL Server 2005. I have more than a dozen reports written and all work well until I add in subreports.
My method for report design is to create reports at design-time based off of a SQL Server view. I then paste the SQL Statement in to a table with tokens in it for fields I want the user to be able to filter on at run-time. For instance, I may have tokens like <START_DATE> and <END_DATE> in the SQL. At run-time the user will give me two dates and I will update the SQL and then set that SQL to the report at run-time. The new SQL statement and the view are identical, except for the dates in the where clause.
On the form that displays the report I have over-loaded the New() method of the form to pass in a report name with full path, and the newly modified SQL statement. I then use code like below to set up the report.
Dim Connection As New OleDbConnection(ConnectionString)
Dim DA As New OleDbDataAdapter(sReportSQL, Connection)
Dim DS As New DataSet
DA.Fill(DS)
Dim strReportPath As String = sReportName
If Not IO.File.Exists(strReportPath) Then
MsgBox("Unable to locate report file:" & vbCrLf & strReportPath)
End If
This works fine for a report without a subreport. When I add a subreport I can not figure out how to update the subreport with a new dataset. What happens is that on any computer other than my design box, the user is prompted for a user name and password for the database. Even if I come over and enter in the sa user name and password, or any valid username and password, the report will not run and you are repeatedly prompted for username and password.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum