|
-
Mar 10th, 2010, 05:06 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Crystal Reports Connection
Hi all,
I'm using the following connection string to connect to my database:
Data Source = 190.190.200.100,1433; Network Library = DBMSSOCN; Initial Catalog = myDataBase; User
ID = myUsername; Password = myPassword;
I designed all my reports using Crystal Reports using a locally hosted copy of my database, but want to allow the Crystal Report to connect to the remote database as indicated by the IP and port above. Is there a way that I can get Crystal Reports to connect using this connection during runtime? Thus change from my local database to my remote database while using an IP?
Thanks in advance!
Last edited by yolandre; Mar 11th, 2010 at 02:21 AM.
-
Mar 10th, 2010, 06:11 PM
#2
Re: Crystal Reports Connection
Please, say :
CR version
Language version
Post the code where you actually are calling the .rpts
-
Mar 11th, 2010, 12:19 AM
#3
Thread Starter
Addicted Member
Re: Crystal Reports Connection
Sorry for not mentioning it earlier, but I'm using:
Visual Studio 2008 Pro
Crystal Reports Basic for Visual Studio 2008
Aslo worth mentioning that I do have an alternative solution to populate the report using a pre-defined datatable, but this means writing a special procedure to populate the datatable being used by each report. Not that I mind doing it, but maintenance is then going to be a pain and I just thought it would be a lot easier to toggle between to two possible connection strings.
-
Mar 11th, 2010, 12:41 AM
#4
Re: Crystal Reports Connection
The next is a way to preview an external .rpt
The .rpt is designed to read data form a sql server using a DSN.
Then you can change the DSN to point to a different server and not the code
Or if you want that one specific client read data from a different server then
you change the DSN on that specific pc and not the code
Code:
Public CRReport As CrystalDecisions.CrystalReports.Engine.ReportDocument
Public CRTable As CrystalDecisions.CrystalReports.Engine.Table
Public CRTLI As CrystalDecisions.Shared.TableLogOnInfo
Code:
CRReport = New CrystalDecisions.CrystalReports.Engine.ReportDocument
CRReport.Load(GRptPath & "RptName.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
For Each Module1.CRTable In CRReport.Database.Tables
CRTLI = CRTable.LogOnInfo
With CRTLI.ConnectionInfo
.ServerName = "MyDSNname"
.UserID = "sa"
.Password = "mypwd"
.DatabaseName = "MyDBName"
End With
CRTable.ApplyLogOnInfo(CRTLI)
Next CRTable
CrystalReportViewer1.ReportSource = CRReport
JG
-
Mar 11th, 2010, 02:19 AM
#5
Thread Starter
Addicted Member
Re: Crystal Reports Connection
Thanks for the reply JGGTZ. I have already tried your proposed solution various times, but could not get anything to work properly and suspected it relates to the ServerName.
After seeing your reply I decided to give it another bash and got it working fine. All it demanded was replacing the actual server name with the IP and port being used to connect to the database: CRTLI.ConnectionInfo.ServerName = " 190.190.200.100,1433". Odd that I tried the same method previously with no success, but now it works and I’m chaffed!
Thanks a stack!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|