Page 1 of 1

Switching SqlOleDb connection string

Posted: Fri Nov 11, 2011 5:37 am
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!!

Switching SqlOleDb connection string

Posted: Mon Nov 14, 2011 1:03 am
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.

Switching SqlOleDb connection string

Posted: Mon Nov 14, 2011 4:54 am
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:

Switching SqlOleDb connection string

Posted: Mon Nov 14, 2011 8:41 am
by Alex K.
Hello,

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

Thank you.