Switching SqlOleDb connection string

Stimulsoft Reports.NET discussion
Post Reply
Girasole
Posts: 16
Joined: Thu Nov 10, 2011 10:33 am

Switching SqlOleDb connection string

Post by Girasole »

Hi!
I created a report using SQL database (sql express). I use OLDB provider for SQL, whit the follow connection string:

"Provider=SQLOleDB;Persist Security Info=True;User ID=xxxxx;Password=yyyyy;Initial Catalog=zzzz;Data Source=localhost;Current Language=Italian;" to design the reports but at run time, it may be required to produce reports with the same database but on different Catalog and PC.

Here is the code I use to do this, but I always get a blank report (no error and no data)...

Code:

Dim r As New Reports.Rep
Dim dbcs As String = String.Empty
dbcs = "Provider=SQLOleDB;Persist Security Info=True;User ID=xxxxx;Password=yyyyy;Initial Catalog=zzzz;Data Source=localhost;Current Language=Italian;"
r.Dictionary.Databases.Add(New Stimulsoft.Report.Dictionary.StiOleDbDatabase("Connection", dbcs))
r.Dictionary.Synchronize()
r.Show()

perhaps it is necessary to bind the new database istance to the datasource created by the designer of Stimulsoft....??

Can someone please help me how to do this?

Thank you all!!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Switching SqlOleDb connection string

Post by Alex K. »

Hello,

In this case, you can add a data source (datatable) too or only change the connection string with help of the following code:

Code: Select all

((StiOleDbDatabase)report.Dictionary.Databases["Connection"]).ConnectionString = newConnectionString;
Thank you.
Girasole
Posts: 16
Joined: Thu Nov 10, 2011 10:33 am

Switching SqlOleDb connection string

Post by Girasole »

Hi Aleksey,
Thank you for replay.
I resolved my problem with your code! :biggrin:

I only had to translate your code in vb.net.
For people who need help to translate...
Code:
DirectCast(report.Dictionary.Databases("Connection"), StiOleDbDatabase).ConnectionString = myConnectionString

Bye
:byebye:
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Switching SqlOleDb connection string

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply