Solved

Crystal Reports RDC making ADO connection in VB

Posted on 2002-04-17
12
311 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

777 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