carmodyk
asked on
Non-Embedded Crystal Report to Change Database Connection at RunTime
Hello Experts,
I am desperately trying to get a Crystal Report, that resides outside of the program, to change databases. I've been able to develop the report based on tables from my SQL database on my local computer, but now when I apply it to the client's computer, it won't work as it keeps asking for the database connection, etc. Here is my Code that I'm working:
Dim cryNoPro As New ReportDocument
Dim ConInfo As New CrystalDecisions.Shared.Ta bleLogOnIn fo
Dim intCount as integer
cryNoPro.Load(System.IO.Pa th.GetDire ctoryName( System.Ref lection.As sembly.Get EntryAssem bly().Loca tion) & "\Reports\MyReport.rpt")
ConInfo.ConnectionInfo.Ser verName = "clientComputer"
ConInfo.ConnectionInfo.Use rID = "clientUSERID"
ConInfo.ConnectionInfo.Pas sword = "clientPassword"
ConInfo.ConnectionInfo.Dat abaseName = "clientDBName"
For intCount = 0 To cryNoPro.Database.Tables.C ount - 1
cryNoPro.Database.Tables(i ntCount).A pplyLogOnI nfo(ConInf o)
Next
crystalReportViewer1.Repor tSource = cryNoPro
What happpens is that the report is loaded, but then it asks for the database connection. And even if you put in the database connection, the report then errors out with the error showing my database connection settings, not the ones I passed to the report! What the heck!!!
Any help would be greatly appreciated.
I am desperately trying to get a Crystal Report, that resides outside of the program, to change databases. I've been able to develop the report based on tables from my SQL database on my local computer, but now when I apply it to the client's computer, it won't work as it keeps asking for the database connection, etc. Here is my Code that I'm working:
Dim cryNoPro As New ReportDocument
Dim ConInfo As New CrystalDecisions.Shared.Ta
Dim intCount as integer
cryNoPro.Load(System.IO.Pa
ConInfo.ConnectionInfo.Ser
ConInfo.ConnectionInfo.Use
ConInfo.ConnectionInfo.Pas
ConInfo.ConnectionInfo.Dat
For intCount = 0 To cryNoPro.Database.Tables.C
cryNoPro.Database.Tables(i
Next
crystalReportViewer1.Repor
What happpens is that the report is loaded, but then it asks for the database connection. And even if you put in the database connection, the report then errors out with the error showing my database connection settings, not the ones I passed to the report! What the heck!!!
Any help would be greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
exp:
crTable.Location = "MyDatabaseName" &
crTable.Location.Substring
".") + 1)
Next
But I'll give you some points for at least trying.