The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Visual Basic


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags:

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 05-22-2008, 11:16 PM
muhunthan muhunthan is offline
Novice
Join Date: May 2008
Posts: 1
iTrader: (0)
muhunthan is on a distinguished road
how to connect CR9 with VB.6

Im new one of the crystal report9. so plz say how to conect CR9 in VB.
thanks lot any inputers

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 06-04-2008, 07:00 PM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 317
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
Code:
    Dim ObjDAO As Object
    Dim ObjDataBase As Object
    Dim ObjRecordSet As Object
Private Sub OpenDataMDBBase()
    Set ObjDAO = CreateObject("DAO.DBEngine.35")
    Set ObjDataBase = ObjDAO.OpenDatabase("C:\Temp\EmpData.mdb")
    Set ObjRecordSet = ObjDataBase.OpenRecordset("DataBaseProject")
End Sub
Private Sub CmdEnd_Click()
    End
    Unload Me
End Sub

Private Sub cmdGo_Click()
    'On Error GoTo ErrorHandalar
    Screen.MousePointer = vbHourglass
    Dim strQryString As String
    If optName.Value = True Then
        Dim strTempQryString As String
        Dim I As Integer
        Dim J As Integer
        J = 1
        strTempQryString = "{DatabaseProject.EmployeeName} ="
        If lstEmployee.SelCount > 1 Then
            For I = 0 To lstEmployee.ListCount - 1
                If lstEmployee.Selected(I) = True Then
                    If J = 1 Then
                        strQryString = strTempQryString & "'" & lstEmployee.List(I) & "'"
                        J = J + 1
                    Else
                        strQryString = strQryString & " Or " & strTempQryString & "'" & lstEmployee.List(I) & "'"
                    End If
                End If
            Next I
        Else
                    strQryString = strQryString & strTempQryString & "'" & lstEmployee.List(lstEmployee.ListIndex) & "'"
        End If
 
    With CrystalReport1
        .ReportFileName = App.Path & "\EmpDetails.rpt"
        .Connect = App.Path & "\EmpData.mdb"
        .DiscardSavedData = True
        .RetrieveDataFiles
        .ReportSource = 0
        .SQLQuery = "Select * from DataBaseProject order by EmployeeName"
        .ReportTitle = "Employee Details Report"
        .Destination = crptToWindow
        .PrintFileType = crptCrystal
        .WindowState = crptMaximized
        .WindowMaxButton = False
        .WindowMinButton = False
        If strQryString <> "{DatabaseProject.EmployeeName} ='Select All'" Then
            .SelectionFormula = strQryString
        End If
        
        .Action = 1
    End With
  End If
  If optDOB.Value = True Then
        If txtFromDate.Text <> "" And txtToDate.Text <> "" Then
            strQryString = "{DatabaseProject.EmployeeDOB} >= #" & Format(txtFromDate.Text, "mm/dd/yyyy") & "# And {DatabaseProject.EmployeeDOB} <= #" & Format(txtToDate.Text, "mm/dd/yyyy") & "#"
        End If
     With CrystalReport1
        .ReportFileName = App.Path & "\EmpDetails.rpt"
        .Connect = App.Path & "\EmpData.mdb"
        .DiscardSavedData = True
        .RetrieveDataFiles
        .ReportSource = 0
        .SQLQuery = "Select * from DataBaseProject order by EmployeeName"
        .ReportTitle = "Employee Details Report"
        .Destination = crptToWindow
        .PrintFileType = crptCrystal
        .WindowState = crptMaximized
        .WindowMaxButton = False
        .WindowMinButton = False
        .SelectionFormula = strQryString
        .Action = 1
    End With
  End If
    Screen.MousePointer = vbDefault
    Exit Sub
ErrorHandalar:
    MsgBox CStr(Err.Number) + Err.Description
    Screen.MousePointer = vbDefault
End Sub

Private Sub Form_Load()
    Call CopyMdbFileInReportLocation
    Call OpenDataMDBBase '//Open MDB DataBase
    Call FillListBox '//Fill List Box With Employee Names
    optName.Value = True
End Sub
Private Sub FillListBox()
    lstEmployee.AddItem "Select All"
    Do While Not ObjRecordSet.EOF
       lstEmployee.AddItem ObjRecordSet.Fields("EmployeeName")
       ObjRecordSet.MoveNext
    Loop
    lstEmployee.Selected(0) = True
End Sub
Private Sub CopyMdbFileInReportLocation()
    '**************Imp Note**********************
    'This procedure is used only to generate the report with out an error, because in crystal report
    'I have specified hard coded database path location ("C:\Temp\EmpData.mdb").
    'When you uninstall or delete the application pl delete database as well.
    '*********************************************
    Dim fso As Object, f As Object, MyFile As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not (fso.FolderExists("C:\Temp")) Then
       Set f = fso.CreateFolder("C:\Temp")
    End If
    If Not (fso.FileExists("C:\Temp\EmpData.mdb")) Then
        Set MyFile = fso.GetFile(App.Path & "\EmpData.mdb")
        MyFile.Copy ("C:\Temp\EmpData.mdb")
    End If
    If (fso.FileExists(App.Path & "\EmpData.mdb")) Then
        fso.DeleteFile (App.Path & "\EmpData.mdb")
    End If
End Sub
Reply With Quote
  #3 (permalink)  
Old 07-17-2008, 03:44 AM
lwinaung lwinaung is offline
Novice
Join Date: Jul 2008
Posts: 8
iTrader: (0)
lwinaung is on a distinguished road
Icon2 Crystal9 Connect toVB.6

Hi,

I am not in touch with VB about 1 year. But I surf from Internet for your result.The example is for Access Database.But you can try SQL Databse when you finished reading the following link.
Please see the followings:

************************************************** *******
Links:
1 - This document describes how to create a Visual Basic application using the Crystal Report Designer Component 9 (RDC). This document covers the basic properties and methods that would be used to create an application that prints, previews, or exports a report. This document is for use with Crystal Reports 9.

Business Objects Online Support

2 - This document describes the new Report Designer Component properties and methods available at runtime to connect your report to its data source. This document is for use with Crystal Reports 9 and later.

Business Objects Online Support

3 - This document describes the methods for creating a deployment package to distribute a Report Designer Component (RDC) 9 application. This document is for use with Crystal Reports 9.

Business Objects Online Support

4 - This file contains a help file for developers using the Report Designer Component (RDC). This utility allows you to navigate through the object hierarchy of the RDC using an 'Explorer tree' type interface. Included are descriptions and/or syntax of objects, collections, methods, and properties.

Business Objects Online Support

------------------------------------------------------------------------------------

How to make a database connection using the Report Designer Component 9

The information in the article refers to:
Report Designer Component 9


Applies to:

Reported version only
Logon and RDC
ConnectionProperties



Synopsis

An application uses the Report Designer Component (RDC) 9 as the reporting development tool. Earlier versions of the Report Designer component used the 'SetLogonInfo' method to log on to the database in the main and subreport.

When using RDC in Crystal Reports 9, what is the recommended method to log on to a database?


Solution

When using the Report Designer Component (RDC), the recommended method to log on to a database in Crystal Reports 9 is the 'ConnectionProperties' method.

The 'ConnectionProperty' method has different properties depending on what type of connection you use in the report.

====================
NOTE:

To check what type of connection you are using:

1. In the Crystal Reports Designer, go to the Database > Set Datasource Location menu.
2. In the 'Current Data Source' dialog box, expand the 'Properties' node.

====================

For a native connection to an Access database, use the following code sample
----------------------------------------------------------------------------------------------

Dim crxDatabaseTable As CRAXDRT.DatabaseTable

For Each crxDatabaseTable In Report.Database.Tables
crxDatabaseTable.ConnectionProperties.Item("Databa se Name") = "C:\Temp\xtreme.mdb"
Next crxDatabaseTable

For an ODBC Connection, use the following code sample
--------------------------------------------------------------------

With External_Report.Database.Tables(1).ConnectionPrope rties
.Item("DSN") = "DSNname"
.Item("Database") = "DBName"
.Item("User ID") = "UID"
.Item("Password") = "PWD"
End With

For an OLE DB Connection, use the following code sample
----------------------------------------------------------------------

With Report.Database.Tables(1).ConnectionProperties
.Item("Provider") = "Provider Name"
.Item("Data source") = "Server Name"
.Item("Initial Catalog") = "Database Name"
.Item("User ID") = "UID"
.Item("Password") = "PWD"
End With


To set the path for an MDW file for an Access Secured Database using System Database Path
-----------------------------------------------------------------------------------------------------------------

Report.Database.Tables(1).ConnectionProperties.Ite m("Session UserID") = "vantech"
Report.Database.Tables(1).ConnectionProperties.Ite m("Session Password") = "vantech"
Report.Database.Tables(1).ConnectionProperties.Ite m("System Database Path") = "\\vanfps12\clo$\session level security\Secured.mdw"


====================
NOTE:

For further information about the 'ConnectionProperties' method go to Business Objects Online Support and search for:

cr_rdc9_connectionproperties.pdf

====================

Hope it will help for u,
LwinAung

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by lwinaung : 07-17-2008 at 03:54 AM.
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 07:08 AM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50