Link to home
Start Free TrialLog in
Avatar of lbsaltzman
lbsaltzman

asked on

Visual Basic, Crystal Reports and RDC

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;"
        With adoTest
            .ConnectionString = strCon
            .ConnectionTimeout = 60
            .Open
            .CursorLocation = adUseClient
        End With
       
        With adoCmd
            .CommandText = "usp_Test"
            .CommandType = adCmdTable
        End With

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

Screen.MousePointer = vbDefault

End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

End Sub


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)

End Sub

Any help I can get to connect the dots and make this run would be greatly appreciated.

   
       
ASKER CERTIFIED SOLUTION
Avatar of DRRYAN3
DRRYAN3

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial