when change connection string Report displayed Empty

Stimulsoft Reports.NET discussion
Post Reply
SayedOthman
Posts: 24
Joined: Sun Dec 29, 2013 7:10 am

when change connection string Report displayed Empty

Post by SayedOthman »

hello every body ,
i have reports that saved in database (sql) ,i want to change connection string during run time i am using procedure as below but when test the code report displayed without data

Code: Select all

 Public Shared Sub PreviewReport(ByVal obj As Object, ReportID As Integer, ByVal Parameter As String)
        Dim report As New StiReport
        report.Load(New MemoryStream(GetReport(ReportID)))
        report.Dictionary.Databases.Clear()
        report.Dictionary.Databases.Add(New Stimulsoft.Report.Dictionary.StiSqlDatabase("Receipt", HelperD.SqlCon.ConnectionString))
        report.Save(New MemoryStream(GetReport(ReportID)))
        report.RegData("Receipt", obj)
        report.Compile()
report("TRXNUMBER") = Parameter
        report.Render(False)
        report.Show()

how to solve this issue ?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: when change connection string Report displayed Empty

Post by Alex K. »

Hello,

Can you please send us your report template for analysis.

Thank you.
SayedOthman
Posts: 24
Joined: Sun Dec 29, 2013 7:10 am

Re: when change connection string Report displayed Empty

Post by SayedOthman »

please check it
Last edited by SayedOthman on Mon Sep 01, 2014 12:44 pm, edited 1 time in total.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: when change connection string Report displayed Empty

Post by Alex K. »

Hello,

In your report the database connection name is "Connection" but you add new connection with "Receipt" name. The names must be identical. Please try to use the following code:

Code: Select all

Dim report As New StiReport
report.Load(New MemoryStream(GetReport(ReportID)))
report.Dictionary.Databases.Clear()
report.Dictionary.Databases.Add(New Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", HelperD.SqlCon.ConnectionString))
report.Save(New MemoryStream(GetReport(ReportID)))
//report.RegData("Receipt", obj)
report.Compile()
report("TRXNUMBER") = Parameter
report.Render(False)
report.Show()
Also you can try to change the connection string, without clear and adding:
((StiSqlDatabase)report.Dictionary.Databases["Connection"]).ConnectionString = newConnectionString;

Thank you.
SayedOthman
Posts: 24
Joined: Sun Dec 29, 2013 7:10 am

Re: when change connection string Report displayed Empty

Post by SayedOthman »

thank you very much Aleksey,
now every thing is ok.
your support highly appreciated
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Re: when change connection string Report displayed Empty

Post by Andrew »

Hello,

We are always glad to help you!
Post Reply