Crystal Reports 6 and Setting MDB File Name and Location 
Author Message
 Crystal Reports 6 and Setting MDB File Name and Location

I'm using Crystal Reports 6 and would like to set the MDB file name and
path in code since this file will be created in run time allowing the
user to
specify a file name and a path they wish to store it in.  I am unable to
find a
way which allows in code (via string variable) to set a specific file
name and
path.  In design time I know there is a way using the Set Location
function.
But, again this doesn't do me any good since the name and path will not
be
unknown until the user creates it.  If anyone knows a way I can assign
an
MDB file name and path in Crystal reports 6 code, please let me know.

Regards,
Tim Hirtle



Mon, 26 Mar 2001 03:00:00 GMT  
 Crystal Reports 6 and Setting MDB File Name and Location
Tim,
   Try this: crp.datafiles(0)=gsdbpath
   gsdbpath is a variable assigned in your program and read from .ini file.



Quote:
> I'm using Crystal Reports 6 and would like to set the MDB file name and
> path in code since this file will be created in run time allowing the
> user to
> specify a file name and a path they wish to store it in.  I am unable to
> find a
> way which allows in code (via string variable) to set a specific file
> name and
> path.  In design time I know there is a way using the Set Location
> function.
> But, again this doesn't do me any good since the name and path will not
> be
> unknown until the user creates it.  If anyone knows a way I can assign
> an
> MDB file name and path in Crystal reports 6 code, please let me know.

> Regards,
> Tim Hirtle



Fri, 30 Mar 2001 03:00:00 GMT  
 Crystal Reports 6 and Setting MDB File Name and Location
Grace Dai replied
Quote:
>Try this: crp.datafiles(0)=gsdbpath

 >  gsdbpath is a variable assigned in your program and read from .ini

Quote:
>file.

This works with Crystal Reports 6 but not with the Crystal Reports 6
Designer component for VB5. The designer does not support the .datafiles()

I now wonder if there is any method of changing the database in the Crystal
reports 6 Designer (the free download version). Or is this component
crippled and of no use in real-world applications? Maybe this is why it is
free?

--
Best Regards - Mike Simpson

Visit our home page at:
http://www.btinternet.com/~genealogy/agene.htm



Fri, 06 Apr 2001 03:00:00 GMT  
 Crystal Reports 6 and Setting MDB File Name and Location
Hi Thomas, I sent in a support request from seagate on this issue.  BTW, they
were excellent on there reply and I had the answer then next day.  Yes, there
is a way to change databases path/file names in the design component.  I tried
their code and it works fine. The following is there reply:

Response To: Tim Hirtle

Hi Tim,

           Thank you for contacting us at Seagate Software Technical
Support.The first thing I would do is check to see if
 "Crystal report 6.0 ActiveX runtime library" is checked.Also make sure any
other librarys you are using in your project are referenced.
I have also included below, example code for the RDC. It shows you how to
connect to MDB file at runtime.

Dim Report As New CrystalReport1
Dim DbName As CRAXDRT.Database
Dim DbTables As CRAXDRT.DatabaseTables
Dim DbTable As CRAXDRT.DatabaseTable
Dim i As Long

Private Sub Form_Load()
'Discard saved data
Report.discardSavedData
'From the Report object , we take the current database used
'with the report and assigns it to DbName using the Database property

Set DbName = Report.Database

'From the Database object DbName, we take all the tables from the database
'used with the report and assign it to DbTables using the Tables property

Set DbTables = DbName.Tables
For i = 1 To DbTables.Count

    'From the DatabaseTables object DbTables, we extract one item (the first
table)
    'using the Item property (in CRW, the tables would be listed in order in
    ''Database|Set Location')
    Set DbTable = DbTables.Item(i)

    'From the DatabaseTable object DbTable, we assign the new location of the
    'database for table 1 using the Location property
    DbTable.Location = "c:\program files\seagate crystal reports\xtreme.mdb"
    'set setsessioninfo for db table to pass your user id and password. Only do
this if you have
    'security.
    DbTable.SetSessionInfo "uid","pass"
Next i
'Verify the database
Report.VerifyOnEveryPrint
'crystal automatically places these on the form.
CRViewer1.ReportSource = Report
CRViewer1.ViewReport

End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

End Sub

Private Sub Form_Unload(Cancel As Integer)
'Distroy the report object this will free up memory
Set report= nothing
End Sub

Reguards

Garrett

Seagate Software IMG

Quote:

> This works with Crystal Reports 6 but not with the Crystal Reports 6
> Designer component for VB5. The designer does not support the .datafiles()

> I now wonder if there is any method of changing the database in the Crystal
> reports 6 Designer (the free download version). Or is this component
> crippled and of no use in real-world applications? Maybe this is why it is
> free?



Sat, 07 Apr 2001 03:00:00 GMT  
 Crystal Reports 6 and Setting MDB File Name and Location
Hi Tim
Thanks for your copy of a response from Seagate, - Great minds think alike -
I had also sent a request to Seagate, and got a similar if shorter response
from them as follows:-
quote

Add the following code to the load event of the form with the Crystal Viewer
on it

Dim DB As craxdrt.Database
Dim DBTables As craxdrt.DatabaseTables
Dim DBTable As craxdrt.DatabaseTable

Set DB = Report.Database
Set DBTables = DB.Tables
For Each DBTable In DBTables
    DBTable.Location = "C:\NewLocation\New.mdb"
Next
CRViewer1.ReportSource = Report
CRViewer1.ViewReport

unquote

As you will see, this is a similar response to yours, I have also tested
this, and it works fine. Along with this response and your earlier response
on displaying a graphic with each record which matches a graphics path name
in the database, I have now managed to produce exactly the reports I need.
--
Best Regards - Mike Simpson

Visit our home page at:
http://www.btinternet.com/~genealogy/agene.htm



Sun, 08 Apr 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Crystal Reports 6 and Setting MDB File Name and Location

2. Crystal Reports 6 and Setting MDB File Name and Location

3. Crystal Reports 6 and Setting MDB File Name and Location

4. Setting path to location of current mdb file

5. crystal reports- setting database location

6. Crystal Report: How to Set Location of OLE object at Run Time

7. Setting Crystal Report Database Location at RunTime...

8. -Help- Setting Crystal Reports.Net Database Location

9. Crystal Reports, Setting Location property takes too long

10. How can i programmically Set Location of my database in Crystal Report of vb.net

11. Crystal Report -- set location of database at run time

12. Crystal Reports - relative path in report file name

 

 
Powered by phpBB® Forum Software