[RESOLVED] Crystal Reports 9 Database Problem
Hello I created a Crystal Report from Access Database. And my application wored good. Now when im trying to run the report from another PC, it says that the path to Database is not valid, and is display the original datbase path.
how do i give the path of Access Database to Crystal Report in my code.
Re: Crystal Reports 9 Database Problem
How Do You Connect Crystal Report To Database..through Dsn Or Any Other Method ?
Re: Crystal Reports 9 Database Problem
This is the Code i use to connect to report.
VB Code:
Dim objCrystal As New CRAXDRT.Application
Dim objReport As CRAXDRT.Report
Set objReport = objCrystal.OpenReport(App.Path & "\Reports\rptPupil.rpt")
objReport.DiscardSavedData
crViewer.ReportSource = objReport
crViewer.ViewReport
Do While crViewer.IsBusy
DoEvents
Loop
crViewer.Zoom (94)
objRS.Close
Form_Resize
Thats It. The Report is depending on a View from the Access Database. At the moment the Report is trying to statically locate the database from its orignial location, i want to give it the path of the Database from where it should load that Recordset.
Re: Crystal Reports 9 Database Problem
why don't you distribute the report with your app?
That way it would be loaded in the app.path above on installation of your app.
Re: Crystal Reports 9 Database Problem
thats exactly what i want actually. and im distributing my reports with my app. i have told you guys the code, give me an example of how to achieve it.
Re: Crystal Reports 9 Database Problem
Your code shows where the report is, not the db. Does your report use a mapped drive?
Re: Crystal Reports 9 Database Problem
this is what im trying to ask you guys, see let me tell you hierarchy of the application. there is an application folder. in that folder i have two subfolders, one for Database and one for Reports. and i do not use Map Drive
again i ask the same question, how do i tell my report that get the data from this folder and this database. How ?
Re: Crystal Reports 9 Database Problem
You can create a dsn on the fly pointing to the database.
Re: Crystal Reports 9 Database Problem
oops crosed threads there m8
Re: Crystal Reports 9 Database Problem
You can set the database location like this
VB Code:
objReport.Database.Tables(1).Location = "path & name of your database"
If this report references more than 1 table, you need to put that line of code for each one. For example if your report referenced a table called 'Cust Names' in the database 'C:\Customers.mdb' and another table called 'Invoices' in the database 'C:\Sales.mdb' your code would look like this
VB Code:
objReport.Database.Tables([color=red]1[/color]).Location = "C:\Customers.mdb"
objReport.Database.Tables([color=red]2[/color]).Location = "C:\Sales.mdb"
The numbers in red are the table ordinals, ie they represent in which order the tables appear in your report file. You can determine this by selecting Database Expert from the Database menu in Crystal. On the right hand side all the tables used in the report will be listed, the first table is '1', the second is '2' and so on.
Re: Crystal Reports 9 Database Problem
yes gr8 ! that did ! thankx alot.