?
Solved

Crystal Reports RDC making ADO connection in VB

Posted on 2002-04-17
12
Medium Priority
?
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
LVL 101

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 101

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 101

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

752 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