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!

Dynamic Server & Database Names With VB

Status
Not open for further replies.

bitsmith2k

Programmer
Mar 5, 2003
34
0
0
CA
Hello, I've designed a few reports using CR 8.5, and have been mainly working on a local server.

The time came this morning to test the reports with VB 6 on the main test server.

This server has a different name, and the database has a different name, although it has the same structure.

My question here is: is there any way to have my server name / database name dynamic in the report file so I don't have to go through and explicitly change the source names in the report?

Thanks
Mike
 
I think that either Ido Millet or Chelseatech have a utility that allows for changing sets of reports globally, hopefully one of them will pipe up here.

Check kenhammady.com for a wealth of resources along these lines.

-k
 
Hope this helps Below is VBSCRIPT code that would allow
you to change the SQL server that the report was using. I am using Crystal 8.5 and 8.0
The important line is
Call reportTable.SetLogOnInfo("SQLNAME", "DATABASENMAE", "USER", "PASSWORD")

Good Luck
Tal

Private Sub printUserReport(sReport )
'3/12/03 TAL

Dim sReportName 'As String
Dim PrintToScreen 'As Boolean
Dim iNumToPrint 'As Integer

Dim CRapp 'As CRPEAuto.Application
Dim report 'As CRPEAuto.report
Dim reportDb 'As CRPEAuto.Database
Dim reportTables 'As CRPEAuto.DatabaseTables
Dim reportTable 'As CRPEAuto.DatabaseTable

sReportName = sReport
iNumToPrint = 1

'Create an Application object with the Crystal Report Engine Automation Server.
Set CRapp = WScript.CreateObject("Crystal.CRPE.Application")

'Obtain a Report object by opening the report file
Set report = CRapp.OpenReport(sReportName)

Set reportDb = report.Database
Set reportTables = reportDb.Tables
Set reportTable = reportTables.Item(1)


'Use Crystals to attempts to prompt for parameters
report.ParameterPromptingEnabled = True

'Tell Crystal what it needs to know to connect to the table below is the test info

Call reportTable.SetLogOnInfo("SQLNAME", "DATABASENMAE", "USER", "PASSWORD")

report.PrintWindowOptions.HasPrintSetupButton = True
report.PrintOut 'True, iNumToPrint,false,1,999

'*******************************************************************
If report.LastErrorString = "" Or report.LastErrorString = "No error." Then
'printing
Else
MsgBox "Error in crystal reports : " & report.LastErrorString, vbCritical
End If


On Error Resume Next
Set CRapp = Nothing
Set report = Nothing
Set reportDb = Nothing
Set reportTables = Nothing
Set reportTable = Nothing

End Sub
 
perfect.. i've been trying a few experimental things that resulted in errors over here, but when i get a chance i'll try your suggestion, tal.

thanks

mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top