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!

pass server name dynamically to crystal reprot using vb 6.0

Status
Not open for further replies.

mandardighe

Programmer
Nov 2, 2001
7
0
0
IN
i have a s/w developed in vb and SQL using crystal report for my reports[.rpt files].i load the setup using package and deployment of vb on the client node.my reports are made using the mssql server option.
when i load the s/w on a client node which is attached to the server whose name is a name other than the default 'server' say 'win98' my reports do not work.it gives me an error 'cannot open sql server'.however when i load the client network utility on the client node and give alias all reports work fine.
is there any way thru which i can set the client utility at run time or is there any way where in i can pass a string in the form of the server name.
i have different clients having the same s/w but different server names, so i cannot hardcode the server name in the report.give me a solution where in i can pass the server name dynamically.
plz let me know.
 
It has been 3 years since I last used Crystal with VB and I no longer have access to the code to check this for certain.
However, I am sure that if you create a Crystal object and run the report using that, there are properties to can amend for the object that allow you to specify the datasource name dynamically just before the report is displayed.

making up object names as I go, it looks something like:

Dim CO as CrystalObject (whatever it is called)
Set CO = new CrystalObject.
CO.Reportname = "whatever"
CO.datasource = "the rightone"
CO.displayreport

You would need to include Crystal in references, and hit F2 to see what functions are available...
 
Hi there.

If i' ve understood correct what is your problem, this is the solution.
i'm using Crystal 9, vb6 and SQL Server 2000.

For i = 1 To Report.database.Tables.Count
Report.database.Tables(i).ConnectionProperties.DeleteAll
Report.database.Tables(i).ConnectionProperties.Add "DSN", DSN
'Report.Database.Tables(i).ConnectionProperties.Add "Server", DatabaseServer
Report.database.Tables(i).ConnectionProperties.Add "Database", DatabaseName
Report.database.Tables(i).ConnectionProperties.Add "User ID", DbUsername
Report.database.Tables(i).ConnectionProperties.Add "Password", DbPassword
Report.database.Tables(i).Location = Report.database.Tables(i).Location
Next

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top