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
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