Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

database connection on crystal report

Posted on 1999-07-14
12
Medium Priority
?
245 Views
Last Modified: 2013-12-25
I have designed a report using crystal report.
In crystal report you should hardcode to point somewhere your database located e.g. c:\abc\abc.mdb
I use VB with Crystal Report activex control to call the crystal report xxx.rpt file. And this application is need to disbute to users. Then when user install my application and the database *.mdb located at different directory that
the *.rpt pointed to. As a result there may have error from crystal report that cannot found *.mdb or no data in the report.
Of course I can open the .rpt file to change the location of the dataabse the user will installed to. But it is not really feasible.

How do the report file know the database location ?
I think this must do with coding but i don't know

0
Comment
Question by:adrianmak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 2

Accepted Solution

by:
alokanant earned 200 total points
ID: 1506640
as far as i can understand your question, the answer is that you can set the database location for the report at run time using the following command -
CrystalReport1.DataFiles(0) = strDBName
where -
CrystalReport1 is the name of the Crystal report you have placed on your form.
strDBName is a string holding the name of the database which has the tables you have associated with the report. This includes the path of the database.

Hope this helps.

alok
0
 

Author Comment

by:adrianmak
ID: 1506641
I have tried your proposed answer but failed.
When I click a command button that call the report, an runtime erro 20507 occur - invalid filename

I added
crystalreport1.datafiles(0)="d:\abc.mdb" in form-load event
do you have any ideas?
0
 
LVL 2

Expert Comment

by:richtsteig
ID: 1506642
Have you set crystalreport1.reportfilename = [YourReport] before to tried to set the datafiles value??
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:CraigLazar
ID: 1506643
hi
what version of Crystal reports are u using ?

Craig
0
 

Author Comment

by:adrianmak
ID: 1506644
rich, no becuase I have hardcode in the active control ?

0
 

Author Comment

by:adrianmak
ID: 1506645
rich, no becuase I have hardcode in the active control ?

0
 
LVL 2

Expert Comment

by:alokanant
ID: 1506646
Are you sure that the file "d:\abc.mdb" exists on the d:\ drive of your PC?
Are you sure the tables used in your report are same as those in "d:\abc.mdb"?
0
 
LVL 2

Expert Comment

by:alokanant
ID: 1506647
Try specifying the reportfile name using the method suggested by Rich at runtime.
I think you must be using CrystalReport1.Action = 1 to run the report from the form.
0
 

Author Comment

by:adrianmak
ID: 1506648
it work now.

0
 

Expert Comment

by:sonalchouhan
ID: 2188145
hi well i have the same problem i want that my report shold pick up the database whereever installed

please help me its urgent

thanks
0
 

Expert Comment

by:sonalchouhan
ID: 2188146
hi well i have the same problem i want that my report shold pick up the database whereever installed

please help me its urgent

thanks
0
 

Expert Comment

by:sonalchouhan
ID: 2188148
hi well i have the same problem i want that my report shold pick up the database whereever installed

please help me its urgent

thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question