Visual Basic, Crystal Reports and RDC
Posted on 2001-07-02
I need some help with a problem using RDC with Visual Basic. My environment is Visual Basic 6.0 and Crystal Report 8.5. I want to build a simple report that uses either unbound fields and/or formula fields. then at runtime have the fields populated for a simple tabular column report to a SQL Server database. Most of the Examples Crystal Reports provide use an MDB file and are useless for client/server. I have purposely kept this example simple. I am trying to connect to a stored procedure with no parameters in it.
The designer builds the following code behind the form with the form with the Crystal Reports viewer on it to which I added the ADO code for connecting to SQL Server:
Dim Report As New CrystalReport1
Private Sub Form_Load()
Dim strCon As String
Dim adoTest As New ADODB.Connection
Dim adoCmd As New ADODB.Command
Screen.MousePointer = vbHourglass
strCon = "DSN=dsnTest; UID=userx; PWD=abcd;"
.ConnectionString = strCon
.ConnectionTimeout = 60
.CursorLocation = adUseClient
.CommandText = "usp_Test"
.CommandType = adCmdTable
CRViewer1.ReportSource = Report
Screen.MousePointer = vbDefault
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
Now I am having a hard time knowing how to connect the dots and populate the report. I have tried creating recordsets and looping through them to populate the report. I have tried inserting the loop into section shown below in the designer object. The best I can do is get one record to display in the detail section.
Private Sub Section10_Format(ByVal pFormattingInfo As Object)
Any help I can get to connect the dots and make this run would be greatly appreciated.