Solved

Cyrstal reports ADO Connection

Posted on 2001-08-04
9
227 Views
Last Modified: 2013-11-23
Hello, I am using Crystal reports to create reports within my VB programs. Right now in order to create a conenction I am having to go through the set location dialog to create the connection to my database (Access 2000) My only problem is that if I then look at the source code of my porgram I can see the password to my database!! What I would like to tdo is use the dynamic ado connection I create within my program for all data access. I create this with code simialr to the following:

  With dbcon
   .Provider = "Microsoft.Jet.OLEDB.4.0"
   .Properties("Jet OLEDB:Database Password") = "password"
   .Open App.Path & "\database.mdb"
  End With

I then refer to dbcon in my recordset connections. Can I get crystal to use this some how? Or is there a way I can set the password at runtime?

Thanks
0
Comment
Question by:Ktoshni
  • 5
  • 2
  • 2
9 Comments
 

Author Comment

by:Ktoshni
Comment Utility
Sorry - when I say I look at the source code and see the password I mean to say if I load the compiled executable into an editor I can see the password. Sorry about that!!
0
 
LVL 12

Expert Comment

by:DRRYAN3
Comment Utility
As far as I know, you will not be able to prohibit anyone from looking at your executable and seeing static strings (those enclosed in quotes).

You could, perhaps, build your password string using the CHR() function and integer constants.  Simplistic, but it would hide your password from any casual observer.

Crystal Reports can make use of recordsets you create on the fly at runtime.  You must create your report using .TTX files and pass the ADO recordset.  You will still have the same problem with the password.
0
 

Author Comment

by:Ktoshni
Comment Utility
I'm still failry new to Crystal, would you be able to give me an example of the method you mentioned? What I have noticed is that strings in my source code which contain the password do not appear when looking at the compiled program in an editor. That's why I'd prefer to use a recordset from within the program.
0
 
LVL 12

Accepted Solution

by:
DRRYAN3 earned 0 total points
Comment Utility
I don't understand.  Where is it that you are able to see the plain text password?  In the Crystal .RPT file, the compiled VB .EXE file, or somewhere else?

If you want to use .TTX (data definition) files for your report, follow the steps below.  Keep in mind that the .TTX file is an ASCII text file describing your recordset structure and fields.

Steps:
1.  Determine structure of the recordset in ADO
2.  Create the .TTX file (see below for option)
3.  Open designer and select More Data Sources->Active Data->Active Data (Field Defs Only) as your data source and browse to the .TTX file.  If you want, you can click the new button (optional) and use the simple Data Definition editor to create it.
4.  Define your report as usual - you can't do a meaningful preview though.
5. In VB, create your ADO recordset, let's call it rsTEST
6. Use something along the following lines to pass the recordset and preview your report.

dim crAppl as CRAXDRT.Application
dim crRep as CRAXDRT.Report
dim rs as ADODB.Recordset

' bunch of code to setup your recordset and load the data into it

set crAppl = new CRAXDRT.Application
set crRep = crAppl.OpenReport("C:\path\report.rpt")
' Set ADO recordset to first table in report
crRep.Database.Tables(1).SetDataSource rsTEST, 3
' Be sure to insert a CR Smart Viewer on form and then
crViewer1.ReportSource = crRep
crViewer1.ViewReport

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:Ktoshni
Comment Utility
Thanks for the help but I think I'll live with how things are.
0
 

Author Comment

by:Ktoshni
Comment Utility
While I would like to find a way of hiding the password. I can live with how the program is being generated
0
 
LVL 2

Expert Comment

by:Lunchy
Comment Utility
I will add this question to the PAQ instead of deleting it, ktoshni, as there is valuable information here that should be in the database.
0
 
LVL 2

Expert Comment

by:Lunchy
Comment Utility
Your points have been refunded and the question has been added to the PAQ database.

Lunchy
Friendly Neighbourhood Community Support Moderator

0
 

Author Comment

by:Ktoshni
Comment Utility
OK - no problem
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now