473,387 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to programmatically set the database file for Crystal Report

144 100+
How to set the database file (MS. Access db) for a rpt file (Crystal report) programmatically in vb6?

the problem is that, the rpt file is referring to the mdb file using an absolute path. so, when i open the project on another computer/different location, it couldn't file the .mdb file.

i've encoutered this problem in .NET where we can set the location of the mdb file programmatically using the ConnectionInfo class of CrystalDecisions.Shared.

is there a similar code that can be done from vb 6?

this is my current code in vb 6 to open and show the report.

Expand|Select|Wrap|Line Numbers
  1.     Dim rpt As New CRAXDRT.Application
  2.     Dim CRreport As New CRAXDRT.report
  3.  
  4.     'refresh data diCR
  5.     Set CRreport = rpt.OpenReport(App.Path & "\lappenjualan.rpt", 1)
  6.  
  7.  
  8.     CRreport.ReadRecords
  9.     CRreport.DiscardSavedData
  10.  
  11.     report.ReportSource = CRreport
  12.     report.ViewReport
  13.  

Thank you.
May 27 '10 #1
3 8754
QVeen72
1,445 Expert 1GB
Hi,

Try this :
Expand|Select|Wrap|Line Numbers
  1. Dim crTab As CRAXDRT.DatabaseTable
  2. For Each crtab In CRreport.Database
  3.     crTab.Location = "C:\MyDB.mdb"
  4. Next 
  5.  
Regards
Veena
May 27 '10 #2
thesti
144 100+
@QVeen72
hi,

thx Veena.

i've tried your it.

actually it is isn't it?

Expand|Select|Wrap|Line Numbers
  1. For Each crtab in CRreport.Database.Tables
  2.  
it opens Ms Access three time (because there are 3 tables i used in the report), ask a confirmation to open the database and close again.

but then an error occurs saying Run-time error 445 "Object doesn't support this action" on line

Expand|Select|Wrap|Line Numbers
  1. CRreport.ReadRecords
i put your suggestion code before the CRreport.ReadRecords. if i put after the ReadRecords and DiscardSavedData, then a messagebox saying "Not Implemented" pops up and the CRViewer shows nothing, just a gray form.


hmm, maybe something is missing. Thank you
May 27 '10 #3
QVeen72
1,445 Expert 1GB
Hi,

yes, you are right.. it should be tables.. and comment the line "Readrecords"...

check this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim rpt As New CRAXDRT.Application 
  3. Dim CRreport As New CRAXDRT.report 
  4. Dim crTab As CRAXDRT.DatabaseTable 
  5.  
  6. Set CRreport = rpt.OpenReport(App.Path & "\lappenjualan.rpt", 1) 
  7. CRreport.DiscardSavedData 
  8.  
  9.  
  10. For Each crtab In CRreport.Database.Tables
  11.     crTab.Location = "C:\MyDB.mdb" 
  12. Next   
  13.  
  14. MyViewer.ReportSource = CRreport 
  15. MyViewer.ViewReport 
  16.  
  17. Set rpt =Nothing 
  18. Set CRreport =Nothing 
  19. Set crTab =Nothing 
  20.  
  21.  
Regards
Veena

Regards
Veena
May 28 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: fanor | last post by:
Hi guys, How can I change at runtime the database for a report?? I need to do this, because my aplication would be installed in any directory. TIA
2
by: fatboy | last post by:
I'm trying to change the database and server on a report that was created using integrated security e.g. report was created pointing to the server 'testserver' and database 'testdb' and at runtime...
0
by: Kalyan | last post by:
I already created report not with crystal report but through .net. Now I want to add new column in my database to crystal report. Field viewer is disabled. If i open crystal report in .net. My...
0
by: bonita | last post by:
I come across the error "CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed." After I move my asp.net code from the development platform (XP professional) to the production web...
1
by: Jason Huang | last post by:
Hi, Would someone tell how to connect my SQL Server 2000 Server to my Crystal Report which shipped with the VS 2003? The reason I asked is I can't find the Field Explorer in my Crystal Report....
0
by: dilchahatahai | last post by:
Hi I am having a problem with crystal report . I can create a crystal reports . (new crystal report ->new->standerd->create new connection->dataset->choose data set->choose table ->add report...
0
by: rami1999 | last post by:
Hi: I am having a problem in running Crystal reports against a cache database (the world fastest database) The reports runs very slow while extracting database record from a cache datase. Does...
7
by: Mohammed Seidu | last post by:
Hi all, Can anyone help me on how to create crystal reports in a .net windows application? The problem is, i have an OleDbConnection object named 'conn' which I create dynamically to connect to...
2
by: hmznzr | last post by:
i am using b.net 2005. i am generating a crystal report. but when i work in a different computer i have to set the location of the database of the report before i generate. is their any dynamic way...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.