Click to See Complete Forum and Search --> : vb crystal reports front end HELPME


eyes0cket
September 9th, 2004, 04:31 PM
Ok, I have no clue how to do this at all but I am hoping you guys can do it in your sleep and advise me....
I have an sql 2000 database and I have been playing around with it using crystal reports, but the managers at work will not be able to figure out how to get data from the database using CR, too much of a learning curve for them.
I took a vb course in collge and I know java pretty well but I have no clue how to write a front end application to access crystal reports for searching the data. This is what work wants me to do, I would think it would be easier to write an application directly that accesses info from the database, but they are asking for a front end web application for CR.

Any ideas??????????????

oh on a side note, "writing this application is not in my job description" not even close to it

malleyo
September 9th, 2004, 06:13 PM
A few questions... What version of CR are you using? Are you trying to write this as an App or as a webpage?

Here's an examle of one way to do it:

Dim lngParam1 As Long

'CrystalReport1 is the name of the dsr file
Dim Report As New CrystalReport1

Dim cdoRowset As CrystalDataObject.CrystalComObject
Dim varArray() As Variant

'Open ADO Connection
Set m_cnAdo = New ADODB.Connection
m_cnAdo.ConnectionString = "DRIVER={SQL Server};UID=[UserID];PWD=[Password]" _
& ";SERVER=[Server];DATABASE=[Database]"

m_cnAdo.Open

Dim rsAdo As ADODB.Recordset
Dim cmdAdo As ADODB.Command

'Using Stored procedure
Set cmdAdo = New ADODB.Command
Set rsAdo = New ADODB.Recordset
cmdAdo.ActiveConnection = m_cnAdo
cmdAdo.CommandText = "sp_StoredProcedureName"
cmdAdo.CommandType = adCmdStoredProc
cmdAdo.Parameters.Refresh
cmdAdo.Parameters("@Param1").Value = lngParam1


'Using Embedded Query
Set cmdAdo = New ADODB.Command
Set rsAdo = New ADODB.Recordset
cmdAdo.ActiveConnection = m_cnAdo
cmdAdo.CommandText = "SELECT * FROM Table WHERE Param = " & lngParam1
cmdAdo.CommandType = adCmdText


Set rsAdo = cmdAdo.Execute

'Using ADO -----------------------------------------------------------------
Report.Database.SetDataSource rsAdo, 3, 1

'Using CDO -----------------------------------------------------------------
' CDO is CR's version of a recordset. Load all your data to an
' Array and pass the array to Crystal
Set cdoRowset = New CrystalDataObject.CrystalComObject

cdoRowset.AddField "Field1", vbString
cdoRowset.AddField "Field2", vbString

ReDim varArray(1)

Do Until rsAdo.EOF
varArray(0) = rsAdo(0).Value
varArray(1) = rsAdo(1).Value

cdoRowset.AddRows varArray

rsAdo.MoveNext
Loop

Report.Database.SetDataSource cdoRowset, 3, 1
'---------------------------------------------------------------------------


CRViewer1.ReportSource = Report
CRViewer1.ViewReport




This uses: VB 6, CR 8.5 using RDC, ADO 2.5

You need to reference:
- Crystal Reports 8.5 ActiveX Designer Run Time Library
- Crystal Reports 8.5 ActiveX Designer Design and RunTime Library
- Crystal Report Viewer Control
- Crystal Data Objects (If you use CDO from the example above)
- Microsof ActiveX Data Objects 2.5 Library (or higher)

You don't need both the Stored Procedure code and the Embedded SQL code, choose one and delete the other.

You don't need both the ADO code (where I've commented ADO) and the CDO code, choose one and delete the other.

The dsr file can be created by clicking 'Project', 'Add Crystal Reports 8.5'

If you need more info on CDO or anything else, do a search either for all posts by me (Malleyo) or for posts containing 'CDO'.

There are many ways to implement CR with VB6, this is just oe of them.

Crstal Reports Suppert:
http://support.businessobjects.com/search/advsearch.asp

Crystal Reports Forum:
http://support.businessobjects.com/forums/default.asp


Good Luck!