Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing database connection

Status
Not open for further replies.

johnugly

Programmer
Jun 21, 2004
31
0
0
BE
hello,
i have a report in CR9 using an oldb command.
So now when I open the database expert I can see the name of the database which i used when creating the connection and underneed the command.
The question is how I can change the database in code in .NET.
I can do it when I use tables but with a command...

Thanks in advance,
john
 
I was able to do it like this using VB6:
[tt]
Dim ConnectionInfo As CRAXDRT.ConnectionProperties

Report.Database.Tables(1).ConnectionProperties.DeleteAll

Set ConnectionInfo = Report.Database.Tables(1).ConnectionProperties
ConnectionInfo.Add "Provider", "SQLOLEDB"
ConnectionInfo.Add "Data Source", "VIDRU"
ConnectionInfo.Add "Initial Catalog", "pubs2"
ConnectionInfo.Add "User ID", "sa"
ConnectionInfo.Add "Password", "pwd"
[/tt]
You should be able to adapt that to .Net. It should work as long as you didn't implicitly write the Command to point to a particular database (e.g. "SELECT au_lname FROM pubs.dbo.authors").

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top