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!

How to connect to a different databases using same report

Status
Not open for further replies.

tumtoo10

Programmer
Dec 10, 2001
40
0
0
US
Hi ,
I have made a report in crystal report , to which i pass a connnection string from my vb application.Now if i pass a string of a different database, the report should should show the data in that database, but it doesn't happens. how to accomplish this. table struct in both the database is exactly the same.
 
Do you have the report set to save the data with the report? If so, uncheck this option in the report options. -This should be the only change you need to make if you are programmatically connecting the report to the database properly. You may not be setting the connection to the database in the report correctly. (If you aren't, you might not be aware of this until you try running the report off a different database than the one you used to build the report.)

You will have had to do some setup before this, but if you got this far, you are on the right track...

(CrTables is a list of tables used in your report-CrTable is a single table in the list)

For Each CrTable In CrTables
CrTable.SetLogOnInfo vDataSourceName, , vUserName, vPassword

'Check for connectivity
If Not CrTable.TestConnectivity Then
'you are on your own from here again...
end if
Next



I assume your report is not using subreports. If it IS using subreports, you'll need to set the logon info for each table in the subreport, as well. Crystal's online help for developer's has examples of this, should my answer be unclear. (CrystalDevHelp.chm)

I hope this helps! LilAmyRae
 
Hi. It is my problem too.

I do all what LilAmyRae sayed. But CrTable.SetLogOnInfo does not connect to server. What should I do?
 
try this instead of SetLogOn Info

With CrystalDbTable.ConnectionProperties
.Item("Server Name") = ODBCDatabaseName
.Item("Database") = ODBCDatabaseName
.Item("User ID") = ODBCUserName
.Item("Password") = ODBCPassword
End With

I called Crystal on this for another problem I was having... LilAmyRae
 
I am facing the same problem, Have any person find out any solution / alternatives ??? Idea is away from realistic person
 
I am also facing the same problem. Solution Pls


I have crystal report that to be run on different databases, with the user selecting which database supplies the data for the report (the tables are the same in each database).

I have successfully done this with a single database using the CR9 RDC combined with the LogOnServer method.

ORACLE Native Database Driver
-----------------------------
Pls give me the solution for multiple database using native oracle database driver dll crdb_oracle.dll

Environment
-----------
Crystal Report 9
ORACLE 8i
Power Builder8.0
Windows NT
 
Here is what I did in my program, hope it helps:

Dim DBTable As CRAXDRT.DatabaseTable
Dim CPProperty As CRAXDRT.ConnectionProperty

For Each DBTable In rptRanking.Database.Tables
Set CPProperty = DBTable.ConnectionProperties("Database Name")
CPProperty.Value = DATABASE_NAME ' Including path and db name

DBTable.SetSessionInfo "", Chr(10) & DATABASE_PSWD
Next DBTable

--Bita
 
Hi,

I have made a report in crystal report 9.0 (may 2003) , to which i pass
logoninfo (server, database, user, pwd) from my VB.NET / ASP.NET
application (Visual studio 2003).It works fine but if i pass a string of a different database
(than in my development environment), the report should show the data in
that database, but it doesn't happen. I get the error: Unable to connect:
incorrect log on parameters.
How to accomplish this? The table structure in both databases is exactly
the same.
1.) We don't save the data with our report.
2.) We logon to each table
Dim crReportDocument As ReportDocument
crReportDocument.SetDatabaseLogon(loginParam.userID, loginParam.password,
loginParam.serverName, loginParam.databaseName)
.... + for all our tables we connect to the database
For Each tbCurrent In crReportDocument.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
tliCurrent.ConnectionInfo = coninf
tbCurrent.ApplyLogOnInfo(tliCurrent)
tbCurrent.Location = tbCurrent.Name
Next tbCurrent
and even for each subreport we do the same.
.....

We receive an error at : tbCurrent.Location = tbCurrent.Name

THX
 
Bitaoo:
where do You put that code? on the designer, or on the form i call the designer??

thanx.. Eli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top