Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > How to Connect a Crystal Report to Oracle, SQL Server, Access via OLEDB

Thread Tools Display Modes
Old 02-04-2003, 09:30 AM
Posts: n/a
Question How to Connect a Crystal Report to Oracle, SQL Server, Access via OLEDB

I have a working VB6 product which will connect one existing Crystal Report 8.5 via the crystal ocx to either an Oracle, Access or SQL Server database - depending on what our customer has.

I am porting this to use the RDC via OLEDB. I use typical code, the important part is below. If a report is authored to a SQL Server database, it will run fine in code against a SQL Server database but if we try to run it against an Access or Oracle database (with the same table structure!) it fails on the .ViewReport line with a message:

'Server has not yet been opened'

My code:

Set Report = crxApplication.OpenReport(ReportsDir & "TestReport.rpt")

For Each crxDatabaseTable In Report.Database.Tables
If DBType = "ORACLE" Then
ODBCDB = "client"
crxDatabaseTable.SetLogOnInfo ODBCDB, "", DBUID, DBPWD
crxDatabaseTable.Location = crxDatabaseTable.Name
ElseIf DBType = "SQLSERVER" Then
ODBCDB = "Northwind"
crxDatabaseTable.SetLogOnInfo SQLServerName, ODBCDB, DBUID, DBPWD
crxDatabaseTable.Location = crxDatabaseTable.Name
crxDatabaseTable.SetLogOnInfo DbName, "", ACCESSUID, ACCESSPWD
crxDatabaseTable.Location = crxDatabaseTable.Name
End If

Next crxDatabaseTable


CRViewer1.ReportSource = Report

Any advice on this will be much appreciated - I can't believe this newer technolgy is going to demand a different report for each database type!
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..