Option Explicit
Dim CRXReport As New CrystalReport1
'The ADO connection to the local database.
Dim cnn1 As ADODB.Connection
Dim datcmd1 As ADODB.Command
'Demonstrate the use of AddADOCommand by opening an ADO data command and adding the data source to the report.
Private Sub cmdADO_Click()
Dim strCnn As String
'Open the data connection.
Set cnn1 = New ADODB.Connection
strCnn = "Provider=SQLOLEDB;SERVER=" + Server + ";DATABASE=" + Database + ";uid=" + User + ";pwd=" + Pass
cnn1.Open strCnn
'Create a new instance of an ADO command object.
Set datcmd1 = New ADODB.Command
Set datcmd1.ActiveConnection = cnn1
datcmd1.CommandText = "Customer"
datcmd1.CommandType = adCmdTable
'Add the data source to the report.
CRXReport.Database.AddADOCommand cnn1, datcmd1
End Sub