|
-
Nov 9th, 2003, 08:46 AM
#1
Thread Starter
Member
Setting database path at Run-Time for Crystal Report
Hi,
I've designed a report based on a ADO database using a connection string. While building the connection string I pointed out the database from which the data is extracted.
The report runs on the development machine no problems, but when I try to run it on a deployment machine I get a Database Error:
"[Microsoft][ODBC Microsoft Access Driver] '(Unknown)' is not a valid path. Make sure the path name is spelled correctly and that you are connected to the server on which the file resides".
I assume that the report tries to look for the database where it was at the design stage.
My question is: how can I set the database's path at run time?
-
Nov 10th, 2003, 02:08 AM
#2
Lively Member
Note that I have a similar thread on this, I spent the whole weekend working on this one. The only way I found that it works always is if I use ODBC. Also if I change the DNS name from that of used by the crystal reports designer I get also into problems.
Still trying to find a solution but it seems that there is some trick somewhere. As a test I created a form with DatabaseName, ServerName, UserId and Password but could not make the system to work always. One of the major issues is the Password authentication with Access. I also noticed that with Crystal ver 9 there are more properties that one can use and possibly making the system more consistent.
-
Dec 5th, 2003, 11:17 AM
#3
New Member
'Try this code: (Working with CR 8.5 and Access 2000)
Public reporte As craxdrt.Report 'Need Crystal Report Viewer Control component installed
'In Form code:
Private Sub ImprimeInforme()
Dim CRXTables As craxdrt.DatabaseTables
Dim CRXTable As craxdrt.DatabaseTable
Set reporte = crxapplication.OpenReport("file.rpt") ' Name of report file
For Each CRXTable In reporte.Database.Tables
CRXTable.Location = App.Path & "\database.mdb" 'Location and name of .mdb
next
frmReportView.show ' Form to show report
end sub
'I hope this can help you..
-
Dec 13th, 2003, 02:35 PM
#4
Hyperactive Member
Okay well first of all I am going to point you to a url which is www.crystalreportsbook.com
and secondly ask you this.
When you designed your reports, did yoou chooose an ADO OLEDB connection onject and then connect to your already built database.
If so wrong, that was my mistake, it embeds in the designer the physical path of the databse and it will only ever take data from there and yes will fail in execution.
Chapter 14, specifically deals with this problem on the book of the URL, I gave you
Sometimes the terminology can be confsuing because what you actuall need to do, is creat an XML datset which contains the structure of your data and not the actual data itself.
It's called whether you use the
'push' or 'pull' data method.
Believe me I have spent weeks, possibly months on this problem and finally got it right.
In summary,ifyou wish to produce reports that are independent of method the default for the designer, no the ways it expects you to build the reports is the pull methodwhere the actual data is , you have to use the 'push.
Just a pointer here in the right direction, reply to this and I if necessary I will give more specifics.
I spent 2 months not full time but 2 months getting this to work the way I wanted to and now have to redo 30 reports because as soon as change my datasource in the designer , I lose all the datafields on the rreports.
-
Dec 13th, 2003, 02:41 PM
#5
Hyperactive Member
Okay well first of all I am going to point you to a url which is www.crystalreportsbook.com
and secondly ask you this.
When you designed your reports, did yoou chooose an ADO OLEDB connection onject and then connect to your already built database.
If so wrong, that was my mistake, it embeds in the designer the physical path of the databse and it will only ever take data from there and yes will fail in execution.
Chapter 14, specifically deals with this problem on the book of the URL, I gave you
Sometimes the terminology can be confsuing because what you actuall need to do, is creat an XML datset which contains the structure of your data and not the actual data itself.
It's called whether you use the
'push' or 'pull' data method.
Believe me I have spent weeks, possibly months on this problem and finally got it right.
In summary,ifyou wish to produce reports that are independent of method the default for the designer, no the ways it expects you to build the reports is the pull methodwhere the actual data is , you have to use the 'push.
Just a pointer here in the right direction, reply to this and I if necessary I will give more specifics.
I spent 2 months not full time but 2 months getting this to work the way I wanted to and now have to redo 30 reports because as soon as change my datasource in the designer , I lose all the datafields on the rreports.
-
Dec 21st, 2003, 04:36 AM
#6
Thread Starter
Member
Hi Richard,
First of all, thanks for your detailed answer.
I've read the 14th chapter but couldn't find the 'ServerName' property used to set an Access database which is the one I use (maybe because I use Crystal Reports 8.5 and not NET).
I've tried the following code but no joy:
For Each tbl In rpt.Database.Tables
tbl.Location = DBPath
Next tbl
I'm yet to try the XML datasets. I'll give it a go if I can't solve the problem in any other way.
Last edited by Shafan; Dec 21st, 2003 at 04:39 AM.
-
Dec 21st, 2003, 05:53 AM
#7
Hyperactive Member
No its there, for access the server name is the database path
-
Dec 21st, 2003, 06:48 AM
#8
Thread Starter
Member
I did a search in the object browser on all libraries but couldn't find 'ServerName' anywhere.
Also - when creating a report and choosing the data source (data explorer), where do I select the XML dataset?
Thanx mate
-
Dec 21st, 2003, 06:57 AM
#9
Hyperactive Member
follow the example in the book, but basically it is project:
add new item
select dataset and add to your project
-
Dec 21st, 2003, 09:19 AM
#10
Thread Starter
Member
I've followed the book's example on how to create the XML file using the IDE, but I can't find the right service through which I can point to my Access database.
Also, I've manually created the XSD file and tried to point to it in the Data Explorer but in which section? The 'Metadata' and 'More Data sources' didn't have an XSD option neither did I find it anywhere else.
Any Ideas?
Thanx
Last edited by Shafan; Dec 22nd, 2003 at 01:20 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|