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

Changing from development database to the live database

Status
Not open for further replies.

Dimondwoof

Programmer
Dec 9, 2002
6
US
I have several CR reports (built in version 9) in a VB.NET project. They were all originally developed pointing to our development database. Now that I try to change their connection to the live database, they still bring up the data from the development database. When I move them to the customer site, they all print with no data at all.

The code that I'm using to set the connection is:

Public Function SetReportConnection(ByVal oRpt As ReportDocument) As ReportDocument
Try
Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
crLogonInfo = oRpt.Database.Tables(0).LogOnInfo
crLogonInfo.ConnectionInfo.ServerName = clsSQLLogin.strServerName
crLogonInfo.ConnectionInfo.UserID = clsSQLLogin.strUserName
crLogonInfo.ConnectionInfo.Password = clsSQLLogin.strPassWord
crLogonInfo.ConnectionInfo.DatabaseName = clsSQLLogin.strDB
oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)
SetReportConnection = oRpt
Catch ex As Exception
MessageBox.Show("SetReportConnection - " & ex.Message & ex.GetType.ToString)
End Try
End Function

This appears to work, in that when I step through the code, the crLogonInfo.ConnectionInfo.DatabaseName shows as the correct database, but the data that is bring displayed on the report is definately from the development database.

Does anyone have any ideas as to what I'm doing wrong?
 
I would open the report in crystal and see if a current connection is set there. Just a shot in the dark...
 
There is a connection but when I remove it, I get all kinds of error messages.
 
What you want to do is change the connection in crystal from your development to your live db.
 
Which would be great, if I had access to the customer's SQL server here at the office. This is supposed to be a product that can be resold. Do you really think that CR is so lame that I have to rebuild all 25 reports every time I want to change the connection to a different server? What about having a report that might look at multiple servers? Do I have to build a different report for each server? This is ridiculous! Crystal Reports SUCK!
 
Well, come to find out, I was missing a crucial line of code. After the ApplyLogOnInfo line, you have to set the location. This is what actually prompts the report to go look for the correct info. The code would look something like this:

crTable.ApplyLogOnInfo(crTableLogonInfo)
Dim strName As String
strName = oRpt.Database.Tables(0).Location.ToString
oRpt.Database.Tables(0).Location = strName
SetReportConnection = oRpt

As you can see, the before and after location setting will be the same, but this like kicks the report in the booty and makes it refresh the connection.
 
I would have originally based the report off of an xml schema. Then applied your login info/datasets to your test or live db, whichever you were using.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top