Print Page | Close Window

Connecting to database

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4587
Printed Date: 26 Apr 2024 at 11:28am


Topic: Connecting to database
Posted By: vjain
Subject: Connecting to database
Date Posted: 21 Oct 2008 at 12:52am
Hi,
  I am working on VB and MS SQL, and generating reports using Crystal Reports 9. Working locally, I am able to configure the CR to connect to the local db.
Once the report is all done, and am sending it to the client, the database properties needs to be changed to the client's server details. Am using OLE DB for this. The client doesnt have CR 9 installed, so how do I change the db properties to the client's, and send it to the client, so that it can work.
 
I tried using the client's DataSource, UserID, etc, but it doesnt connect, maybe because of Firewall issues. Is there a way, where it can be coded? Or any other suggestions?
 
Thanks



Replies:
Posted By: lockwelle
Date Posted: 05 Dec 2008 at 6:31am
If you are using .net, this will work as I use it and it runs fine.  Since you are using OLE.
Dim reportDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument

reportDoc.Load(strReportPath, CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)

Try

''fb1888 RT 3/26/08 dynamically sets the datasource

Dim myDataSourceConnections As CrystalDecisions.Shared.DataSourceConnections = reportDoc.DataSourceConnections

Dim myConnectInfo As CrystalDecisions.Shared.IConnectionInfo = myDataSourceConnections(0)
myConnectInfo.SetConnection(SQLServer, Database, DatabaseUser, DatabasePassword)

CRViewer.ReportSource = reportDoc

CRViewer.Refresh()

Unfortunately, it requires knowledge of how the connection to the database is made...username, password, server, and database.

Hope this helps



Print Page | Close Window