Solved

Crystal Reports RDC making ADO connection in VB

Posted on 2002-04-17
12
309 Views
Last Modified: 2012-06-27
I have a VB application that I have installed the Report design control into to allow users to create reports at run time. I want to place a pre connected report in the designer with the database connections already created as a template. Here is the code I am trying to use to make a database connection via ODBC to a SQL database with an odbc connection called "Leas" Can anybody see what I am doing wrong. This is example code that that I am trying to tweak to work for me. When I try to run it is stops at the first "Set ADOConnection" and states that I am "trying to use an invalid outside procedure"



Dim ADOConnection As ADODB.Connection
Dim ADOCommand As ADODB.Command

''Beginning of Database connections
    ' Open the data connection
    Set ADOConnection = New ADODB.Connection
    ADOConnection.Open "Provider=MSDASQL;Persist Security Info=False;Data Source=Leas Database;Mode=Read"

    ' Create a new instance of an ADO command object
    Set ADOCommand = New ADODB.Command
    Set ADOCommand.ActiveConnection = ADOConnection
    ADOCommand.CommandText = "Orders"
    ADOCommand.CommandType = adCmdTable

    ' Add the datasource to the report
    Report.Database.AddADOCommand ADOConnection, ADOCommand
0
Comment
Question by:DavidNPD
  • 6
  • 3
  • 3
12 Comments
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6949745
You've added the appropriate version of ADO to your project references?

This is happening on your development machine, or on end user machine?

The error message you've provided in quotes does not exist on the MS MSDN or KB sites.  Is there a different message being returned?


DRRYAN3
0
 

Author Comment

by:DavidNPD
ID: 6950348
I believe I have the correct references installed, I am making other ado connections to this database in othere areas of the app. WOuld you know what reference I need for this type of connections?

This is my development machine.

Could this be a error generated directly from Crystal and that is why it is not on MSDN? the wording "trying to use an invalid outside procedure" is a exact.
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6950530
The code above has nothing to do with Crystal until the last line.  The rest is all ADO stuff.  

Did you setup security on the SQL server?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6950725
it appears you have used parts of two different connection methods.

ADOConnection.Open "Provider=MSDASQL;Persist Security Info=False;Data Source=Leas Database;Mode=Read"


The standard ODBC connection looks like
ADOConnection.Open "Provider=MSDASQL;DSN=Northwind;UID=sa;PWD=;"

The OLE DB connectiion looks like
ADOConnection.Open "Provider=SQLOLEDB;Persist Security Info=False;Data Source=Leas Database;Mode=Read"

You may also be having trouble because of the blank in the Data source.

mlmcc
0
 

Author Comment

by:DavidNPD
ID: 6951569
DDRYAN3, I do have security on the server as I get in to the database with this "Leas" odbc connection in other software.

mlmmcc, You are right that was a type in my string with the space. I corrected that and still have the same issue. I copied this connection code directly from an example app so I am entirely unfamilier with it. Can you tell what lines should be removed or modified?

Here is the modified one:

Dim ADOConnection As ADODB.Connection
Dim ADOCommand As ADODB.Command

    ' Open the data connection
    Set ADOConnection = New ADODB.Connection
    ADOConnection.Open "Provider=MSDASQL;Persist Security Info=False;Data Source=Leas;Mode=Read"

    ' Create a new instance of an ADO command object
    Set ADOCommand = New ADODB.Command
    Set ADOCommand.ActiveConnection = ADOConnection
    ADOCommand.CommandText = "Orders"
    ADOCommand.CommandType = adCmdTable

    ' Add the datasource to the report
    Report.Database.AddADOCommand ADOConnection, ADOCommand
0
 

Author Comment

by:DavidNPD
ID: 6951591
DDRYAN3, I do have security on the server as I get in to the database with this "Leas" odbc connection in other software.

mlmmcc, You are right that was a type in my string with the space. I corrected that and still have the same issue. I copied this connection code directly from an example app so I am entirely unfamilier with it. Can you tell what lines should be removed or modified?

Here is the modified one:

Dim ADOConnection As ADODB.Connection
Dim ADOCommand As ADODB.Command

    ' Open the data connection
    Set ADOConnection = New ADODB.Connection
    ADOConnection.Open "Provider=MSDASQL;Persist Security Info=False;Data Source=Leas;Mode=Read"

    ' Create a new instance of an ADO command object
    Set ADOCommand = New ADODB.Command
    Set ADOCommand.ActiveConnection = ADOConnection
    ADOCommand.CommandText = "Orders"
    ADOCommand.CommandType = adCmdTable

    ' Add the datasource to the report
    Report.Database.AddADOCommand ADOConnection, ADOCommand
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:DavidNPD
ID: 6951594
I just realized the text of the error is not Exactly what I said, here is the correct one, When I attempt to run the code I get a dialog with this:

"Compile Error"

"invalid outside procedure"
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6951643
What version of ADO do you have or is ADO even installed on your machine?

mlmcc
0
 

Author Comment

by:DavidNPD
ID: 6952484
Sorry to sound stupid but How would I check that version #?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6953558
I think there is program you can runto check.  I'm not at work but when I get back on Monday I'll run it down for you.

mlmcc
0
 
LVL 12

Accepted Solution

by:
DRRYAN3 earned 50 total points
ID: 6953822
Re: version check program - go to http://www.microsoft.com/data and you can download and install both ADO (MDAC v2.5 or v2.6) and the MDAC version checker.
0
 

Author Comment

by:DavidNPD
ID: 7114022
DDryan, I ended up solving this by an entirely different route,  but thanks for the assistance.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now