Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...(I) have been able to get my problems solved from past messages and also new posts that other users have responded to promptly..."

Geography

Where in the world do Tek-Tips members come from?

Business Objects: Crystal Reports 2 Data Access FAQ

Data Access for the Developer using Crystal Reports
Posted: 11 Mar 01

Data Access for the Developer using Crystal Reports.

As there are a number of differing methods of using CR as a developer, I have outlined the procedure for establishing data access for the following:

Using the Report Designer Component (craxdrt.dll) with Visual Basic

Having set up your Report Object as follows:
    Dim CRXReport As CRAXDRT.Report
    Set CRXReport = New CrystalReport1
Or
    Dim CRXReport As New CrystalReport1

1)    with Datafile data source (e.g. Btrieve, Paradox, dBase, MSAccess etc.)

         Set CRXTables = CRXReport.Database.Tables
         Set CRXTable = CRXTables(1)
         CRXTable.Location = “C:\Program Files\Seagate Software\Crystal Reports\Samples\Databases\Xtreme.mdb”

2)    with SQL Native connection data source (e.g. MS SQL Server)

        Set CRXTables = CRXReport.Database.Tables
        Set CRXTable = CRXTables.Item(1)
 CRXTable.SetLogonInfo  “TheSQLServer”, ”pubs”, ”Admin”, ”Admin”
Or
        CRXTable.SetLogonInfo<servername>,<databasename>,<userid>,<password>

3)    with ODBC connection

        Set CRXTables = CRXReport.Database.Tables
        Set CRXTable = CRXTables.Item(1)
        CRXTable.SetLogonInfo “Xtreme Sample Database”,”Xtreme”,”Admin”,””
Or
        CRXTable.SetLogonInfo<ODBC_DSN>,<databasename>,<userid>,<password>


4)    ADO Recordset

Having first defined your recordset as follows:
    Dim rs As New ADOR.Recordset
    rs.Open “Select * From Customer”, “Xtreme Sample Database”
Then
        Set CRXTables = CRXReport.Database.Tables
        Set CRXTable = CRXTables.Item(1)
        CRXTable.SetDataSource rs
Or
        CRXTable.SetDataSource  <recordset>

5)    with OLEDB Providers (e.g. MS Access)

        Dim cnn1 As New ADODB.Connection
        Dim datcmd1 As New ADODB.Command
        Dim strCnn As String
        Set cnn1 = New ADODB.Connection
        strCnn = “Provider=MSDASQL;DSN=Xtreme Sample Database;UID=Admin;PWD=”
        cnn1.Open strCnn
        Set datcmd1 = New ADODB.Command
        Set datcmd1.ActiveConnection = cnn1
        datcmd1.CommandText = “Customer”
        datcmd1.CommandType = adCmdTable
        CRXReport.Database.AddOLECommand cnn1,datcmd1
Or
CRXReport.Database.AddOLEDBSource “DSN=Xtreme Sample Database;DBQ=xtreme.mdb;DefaultDir=c:\Program Files\Seagate Software\Crystal Reports\Samples\Databases;Driver=odbcjt32.dll;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;”,”Customer”

Or for MS SQL Server

Provider=SQL_OLEDB;Server=TechTest;Database=Pubs;UID=Admin;PWD=sa

NOTE the reference to SQL_OLEDB above is not the correct entry - remove the underscore in use - it's only there because I keep getting an emoticon for

Or for Oracle

Provider=MSDAORA; PWD=password ; User ID=Admin;Datasource=TheOracleServer

Using the Report Designer Component (craxdrt.dll) with Visual Interdev

Having created your Application and Report objects as follows:

        If Not IsObject (session("oApp")) Then
        Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
        End If

        Path = Request.ServerVariables("PATH_TRANSLATED")
        While (Right(Path, 1) <> "\" And Len(Path) <> 0)
 iLen = Len(Path) - 1
        Path = Left(Path, iLen)
        Wend

'This "While/Wend" loop is used to determine the physical path (eg: C:\) to the 'Crystal Report file by translating the URL virtual path (eg: http://Domain/Dir)

        If IsObject(session("oRpt")) then
        Set session("oRpt") = nothing
        End if

        Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)

You can then execute the SetLogonInfo method as follows:

        userid = "Seagate"
        password = ""
        set crtable = session("oRpt").Database.Tables.Item(1)
        crtable.SetLogonInfo "Automation", "pubs", cstr(userid), cstr(password)

Back to Business Objects: Crystal Reports 2 Data Access FAQ Index
Back to Business Objects: Crystal Reports 2 Data Access Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close