Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Changing Data Source at runtime for Crystal Report

Status
Not open for further replies.

taranis

Programmer
Jan 31, 2001
20
0
0
US
I'm using VB6 and Crystal 8 to display a report. I want to change the data source at runtime. When I try to do this I get the following error "Data Source name too long". I changed the path and name of the Data Suurce name so that it was 8 characters long and I still get the same error.

I am new to Crystal reports for the most part so I am probably doing something stupid. The report was working fine in the project but it used the crystal API's. I now want to use the Cyrstal Designer that comes with version 8.



Source code is shown below:
Note: The rs is returning a valid record set and contains all of the displayed fields in the Report.



Private Report As New CrystalReport1
Private rs As New adoDB.Recordset
Private db As New adoDB.Connection

Private Sub Form_Load()

Dim strString As String
Screen.MousePointer = vbHourglass
strSQL = "SELECT Imex.DataFileType, Imex.Description,Imex_Log.ImexLogId,Imex_Log.ImexName,Imex_log.DataFile,Imex_log.DataFileDateTime,Imex_Log.StartDateTime,Imex_Log.EndDateTime,Imex_log.UserId," _ & "Imex_log.Comments,Imex_Report.ReportId,Imex_Report.ReportText FROM (ImEx_Log INNER JOIN ImEx_Report ON ImEx_Log.ImExLogID = ImEx_Report.ImExLogID) INNER JOIN ImEx " _
& "ON ImEx_Log.ImExName = ImEx.ImExName where IMEX_Log.IMEXLOGID =" & frmImExLogs.LOGID

db.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Program Files\Microsoft Visual Studio\Projects\IMEX_E_Working\IMEX_NEW_GE1.MDB"
rs.Open strSQL, db, adOpenKeyset, adLockBatchOptimistic

Report.Database.SetDataSource rs
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
 
Try:

Report.Database.SetDataSource rs, 3

Also, was the report design using the Active Data Driver? You can only pass a recordset to reports designed with the Active Driver. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
its an old report held over from version 6, so I
dont think it was designed with the active driver. Can I easily convert it ovrer to use the active driver?
 
This may sound unbelievable, but from my research and experience you can only convert it if it uses only one table/view. If it uses linked tables, it has to be recreated from scratch, using the active data driver.

I suggest that you create a simple report using the active data driver and implement it all the way to a simple VB application. That way you will see the process, and can limit your troubleshooting to the VB/CR interface. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
As you suggested, I had to create the report from scratch using the VB6 designer then there was no problem. Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top