Programatically change SQL database connection

Stimulsoft Reports.NET discussion
Post Reply
WilliamCcy
Posts: 10
Joined: Sat Jul 21, 2007 6:18 am
Location: Malaysia,KL

Programatically change SQL database connection

Post by WilliamCcy »

Hi,

Currently, im changing my report designer from crystal report to StimulReport, and
Im using VB.net 2007 as my development tool.

But here is the problem,

I would like to change the:
1) SQL Database connection info (e.g: Server Name, DB Name, Login Name, Password ... etc)
2) SQL Table Location
3) Record Selection Formula (previously im using Crystal Rpt which provide this )
in programatically for each table instead of using the default connection ( The SQL database connection when designing report).

Can someone pls help me?? im a newbie in stireport. thanks!




Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Programatically change SQL database connection

Post by Guest »

You can use following code, for example:

Code: Select all

Dim database As StiSqlDatabase = TryCast(report.Dictionary.Databases.Item("Connection"), StiSqlDatabase)
If (Not database Is Nothing) Then
database.ConnectionString = "Password=;Data Source=SQLEXPRESS;Integrated Security=True;Initial Catalog=Northwind;User ID="
End If
Instead Crystal Formula you can use a "variables":

Code: Select all

report.Dictionary.Variables.Add("MyVariable", GetType(Integer))
report.Dictionary.Variables("MyVariable").Value = "1000"
Thank you.
WilliamCcy
Posts: 10
Joined: Sat Jul 21, 2007 6:18 am
Location: Malaysia,KL

Programatically change SQL database connection

Post by WilliamCcy »

Thanks for advice, its helps a lot. :biggrin:
Post Reply