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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to dynamically set the database connection in Crystal Reports

Status
Not open for further replies.

MMProgrammer

Programmer
Sep 12, 2003
5
0
0
US
I am unable to dynamically set the database connection in Crystal reports and I wondered if anyone had figured out how to do this. I can set the database connection using the Crystal reports Viewer but I have not found code on how to do it dynamically. I have looked on the but have had no luck. Does anyone know how to set it dynamically?
 
If you are instantiating CR Viewver for displaying CR report on webpage, you can add following to CR Viewver code for conncting DB dynamically.

webSource.AddParameter "user0" "userid"
webSource.AddParameter "password0" "password"

if any prompts required..

webSource.AddParameter "Prompt0" "prompt0Value"
webSource.AddParameter "Prompt1" "prompt1Value" ...

Hope this may help you
Rama Kommineni






 
I am going through a VB.Net application and I am unable to set the connection any other way but by changing Crystal Reports set location parameter. Since I have multiple reports I would like to set the location dynamically in VB.NET code for all the reports so I do not have to do the set location in Crystal Reports 20 times. Any suggestions?
 
This is the code I use. Remember if you use sub reports that you must loop thru them also.

crDatabase = crRepDoc.Database
crTables = crDatabase.Tables

For Each crTable In crTables
With crConnInfo
If UseRptServer = True Then
.ServerName = ConfigurationSettings.AppSettings("ReportServerName")
.DatabaseName = ConfigurationSettings.AppSettings("ReportDatabaseName")
.UserID = ConfigurationSettings.AppSettings("ReportUserID")
.Password = ConfigurationSettings.AppSettings("ReportPassWord")
Else
.ServerName = ConfigurationSettings.AppSettings("OLEDBServerName")
.DatabaseName = ConfigurationSettings.AppSettings("OLEDBDatabaseName")
.UserID = ConfigurationSettings.AppSettings("OLEDBUserID")
.Password = ConfigurationSettings.AppSettings("OLEDBPassWord")
End If
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crConnInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next


Regards
Chuck LaRue
ADRS Computer Services
 
Chuck, in your code have you used CRAXDRT to get these methods? And unlike Crystal.Engine you don't need to hardcode the password?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top