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