Page 1 of 1

when change connection string Report displayed Empty

Posted: Sat Aug 30, 2014 4:47 am
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 ?

Re: when change connection string Report displayed Empty

Posted: Mon Sep 01, 2014 6:28 am
by Alex K.
Hello,

Can you please send us your report template for analysis.

Thank you.

Re: when change connection string Report displayed Empty

Posted: Mon Sep 01, 2014 10:24 am
by SayedOthman
please check it

Re: when change connection string Report displayed Empty

Posted: Mon Sep 01, 2014 12:36 pm
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.

Re: when change connection string Report displayed Empty

Posted: Mon Sep 01, 2014 12:56 pm
by SayedOthman
thank you very much Aleksey,
now every thing is ok.
your support highly appreciated

Re: when change connection string Report displayed Empty

Posted: Tue Sep 02, 2014 4:07 am
by Andrew
Hello,

We are always glad to help you!