Set Location in Crystal Report

isityou
01-11-2004, 08:37 PM
hi ... is there any way to set the location to a database during run-time instead of design time? currently i m using vb's crystal report component (the report is inside vb).. thanks

NimX
01-11-2004, 08:43 PM
hi,
i think you cannot do it runtime but if you are doing setLocation with ODBC then you can set report Logon information at runtime and configure your datasource.
or Look at this
http://support.businessobjects.com/library/kbase/articles/c2010371.asp

NimX
01-11-2004, 08:56 PM
or you can look at this too.. if you are facing such problem.. this will help you to decide what to do..
http://support.businessobjects.com/library/kbase/articles/c2011321.asp
Actually i don't understand your problem.. you are looking for that to do it in that way or you face some problem and so you are looking for that.

isityou
01-11-2004, 09:28 PM
hi..thanks for replyin... i ll check out the website that u gaf... i wanted to set the l.ocation during run time so that it would be more flexible cos i do not wan it to be hard coded as the location will change frequently... thanks again :P

Optikal
01-11-2004, 09:43 PM
I'd recommend retrieving your data into a recordset through VB code, then use the reports .Database.SetDataSource method to pass the recordset to the report at runtime.

NimX
01-11-2004, 10:00 PM
hi..thanks for replyin... i ll check out the website that u gaf... i wanted to set the l.ocation during run time so that it would be more flexible cos i do not wan it to be hard coded as the location will change frequently... thanks again :P
oh, if only that's the case that you don't want to make it hardcoded than the address i gave you above will solve your problem.
Best of Luck,
Have fun,

isityou
01-11-2004, 11:11 PM
nimesh: tqtq... i m checking it now :)

optikal: i haf done that already but the report stil points to another database. i have 2 databases... and the report kept pointing to the old database... and when i check.. the 'set location' was not pointing to the new database...so i had to manually modify the path.. which means its hardcoded... thanks for your reply :)

Optikal
01-11-2004, 11:13 PM
When you set up the data source in your report, go to Other Data Sources -> Active Data -> Field Definitions Only

Thats what I use for all reports I make and I've never had any problems.

NimX
01-12-2004, 12:15 AM
Thanks Optikal.. You have passed me in information that i was looking for but not posted in any forum.

MKoslof
01-12-2004, 06:29 AM
Hmm..Optikal is speaking about .ttx data definition files. I feel the message being conveyed here is that you can NOT change the location of a database location at run-time..this is NOT true. There are some limitations, but if you have the same provider and database type, you CAN dynamically pass a database table or location.

If you let me know some details about what you are trying to do, I probably get you going in the right direction. And, I need to know what database type you are using for the report.

isityou
01-12-2004, 06:51 PM
optikal: i noe that if i use Other Data Source etc connection, this problem wil not occur.. but the problem is that i m redeveloping a rather old application that was developed by some other person..and this person did not use Other Data Source connection. I have no idea how he/she connects the report to the database as i dunno how to check. i have to redevelop tis program is a short period to save resources, so as agreed with my company, i will redevelop the functions but maintain the reports... if i change the current old connection to Other Data Source, that would mean i have to readd the database and redesign the reports... so whenever the location of the database changes, the reports doesnt work as it was hardcoded...

mkoslof: this application of mine doesnt have a setup file, so there's no registration of database path watsoever. however i do have an .ini file. the database path is taken from this .ini file and then passed to the application during run time. in the old program, i think the reports are connected this way too but i have no way to confirm that as the old project file was corrupted. currently i'm using Ms Access Database, all the crystal reports are in the VB project itself. what i wanted was the report path to be set in the .ini file, and then the application takes this path and connects it to the correct database during runtime

MKoslof
01-13-2004, 06:12 AM
"mkoslof: this application of mine doesnt have a setup file, so there's no registration of database path watsoever. however i do have an .ini file. the database path is taken from this .ini file and then passed to the application during run time. in the old program, i think the reports are connected this way too but i have no way to confirm that as the old project file was corrupted. currently i'm using Ms Access Database, all the crystal reports are in the VB project itself. what i wanted was the report path to be set in the .ini file, and then the application takes this path and connects it to the correct database during runtime"



Well....if you have no clue how this report is connecting in the VB project can you at least open the reports in Crystal and find out what connection type you are using? Are these native .rpt files? Now if you don't have access to the VB project file AND you can't open the reports and get to the report designer there isn't much I can recommend to you...because I don't know whats going on. You say this report connects to an ini file in order to find the database path. Can't you write some script to modify the ini file?....once you modify the ini file the Crystal Report *in theory* will change its data location to where the ini file dictates. I say *in theory* because I don't know what code is used for this or what procedures are being called...so I can't confidently give you an answer. If you modify the ini file, does the report change data locations?

isityou
01-13-2004, 06:51 PM
mkoslof: in the old program, all the reports were not included into the Vb project, its a separate .rpt file. and the report path is taken from the .ini file, so whenever the path changes the connection path will also change... however i have checked the codes... this old program connects the report to the database using a .ocx file..

for instance there is this .ocx named ISMCrw32... i never heard of this type of ocx file, so i assume its a user defined ocx.. however i couldnt find the project file that built this ocx file, so i do not noe how to connect the report to the database based on the file specified in the .ini.. In the old project the codes are briefly as follow

Dim mtObject as ISMCrw32

with mtObject
.RptDBName = mstrReportDir
'== mstrReportDir is a global variable and is the path to the database
'== set in the.ini file
'RptName = "INVOICE.rpt"

end with

i guess if i still couldnt change the connection like how the old program does.. then i will haf to redesign the reports and connect them using More Data Sources etc.. thanks for all your replies anyway :)

MKoslof
01-14-2004, 07:00 AM
At this point I recommend trying to re-develop your report with the RDC. If you are not sure how this application was developed and you do not have all the source code, or you can't follow all of the source code, you should probably re-write this application so you know how all the components run.

If I tried to help you fix this, it wouldn't be productive, because if something else breaks, we don't know where in the originial source code to troubleshoot :). Re-write this so you are familiar with all components

isityou
01-14-2004, 06:51 PM
i finally gaf up and started redeveloping the reports yesterday :P anyway thanks for all of your suggestions... :)

MKoslof
01-15-2004, 06:37 AM
OK, let us know if you stuck along the away..and we will try to offer advice

fshrago
03-23-2004, 02:35 PM
OK, let us know if you stuck along the away..and we will try to offer advice

I have a report which was created in the RPC in VB6 but it is linked to a Dataenvironment.

I believe I have the correct code to change the location of both the dataenvironment and the crystal report but the crystal report is still looking for the data in the hardcoded folder.

Here is the code I am using:

Dim Report As New CRPQuestion
' Change the Connection object of the data environment to point to the new database
DataEnvironment1.Connection1.Open dbPath
Report.Database.SetDataSource (DataEnvironment1.rscmdByQID)
Report.RecordSelectionFormula = "{ADO.QuestionID} =" & rsQuestion("QuestionID")
'printout without prompting user
Report.PrintOut False, 2

Any suggestions as to what I am doing wrong?

Thanks

MKoslof
03-23-2004, 05:08 PM
You still need to set the location of the Report's tables at runtime. What database type are you using..if you are implementing the data environment I assume you are using Access. If so, pass the report's table location the App.Path directory or where the database resides.

Report.Database.Tables(1).Location = App.Path & "\myDb.mdb"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum