DataEnvironment.Connection.Provider = ... gives error

DataEnvironment.Connection.Provider = ... gives error

Post by news.microsoft.co » Sat, 02 Jun 2001 22:06:45



I am trying to write a application that is switchable between Access and SQL
at run time.

When I execute the following code snippet at init I get a run time error:

    DataEnvironment1.TestConnection.Provider = "SQLOLEDB.1"

The error is:

    Run-time error '3220': Supplied provider is different from the one
already in use.

The connection is not already open so I don't understand the reason for the
error.  I know I can create the objects all in code and not have this
problem but I want to design the forms with the visual instance of the
obect.

TIA

Sean Smith

 
 
 

DataEnvironment.Connection.Provider = ... gives error

Post by Stefan Berglun » Mon, 04 Jun 2001 05:53:13


The dataenvironment opens itself when your form loads. Try closing it before
switching to another provider. Below is a code snippet showing how that is
done. The dataenvironment is named devShowTime and the only connection
object is named dcnShowTime. Change them to your names or pass them as
parameters to the routine if you have more than one.

Private Sub DEvClose()

  Dim X As ADODB.Connection
  Dim cmd As ADODB.Command
  Dim rst As ADODB.Recordset

  On Error Resume Next
  For Each cmd In devShowTime.Commands
    Set X = cmd.ActiveConnection
    If (X.State = adStateOpen) Then Set X = Nothing
  Next
  For Each rst In devShowTime.Recordsets
    Set X = rst.ActiveConnection
    If (X.State = adStateOpen) Then X.Close
    If (rst.State = adStateOpen) Then rst.Close
    Set X = Nothing
  Next
  If (devShowTime.dcnShowTime.State = adStateOpen) Then
devShowTime.dcnShowTime.Close
  Exit Sub

BigProblem:
  MsgBox Err.Description

End Sub

Stefan


Quote:> I am trying to write a application that is switchable between Access and
SQL
> at run time.

> When I execute the following code snippet at init I get a run time error:

>     DataEnvironment1.TestConnection.Provider = "SQLOLEDB.1"

> The error is:

>     Run-time error '3220': Supplied provider is different from the one
> already in use.

> The connection is not already open so I don't understand the reason for
the
> error.  I know I can create the objects all in code and not have this
> problem but I want to design the forms with the visual instance of the
> obect.

> TIA

> Sean Smith


 
 
 

1. DataEnvironment.Connection.Provider = ... gives error

I am trying to write a application that is switchable between Access and SQL
at run time.

When I execute the following code snippet at init I get a run time error:

    DataEnvironment1.TestConnection.Provider = "SQLOLEDB.1"

The error is:

    Run-time error '3220': Supplied provider is different from the one
already in use.

The connection is not already open so I don't understand the reason for the
error.  I know I can create the objects all in code and not have this
problem but I want to design the forms with the visual instance of the
obect.

TIA

Sean Smith

2. US - NYC - Sybase/Unix/C Developers - Several Investment Banks

3. Help! dataenvironment connection gives error 713

4. ASA V8 CREATE TABLE public.MYTABLE fails

5. Stringizing gives c preprocessing error with Pro*C v2

6. setWorkingDir()

7. ODBC DSN connection from IIS to SQL7 gives error

8. Keyword Searches

9. Conection to a Remote SQL Server through ODBC ,giving Connection Errors

10. Connection error on XP Pro: SQL Server 2000 Evaluation Version

11. FileMaker Pro connection error

12. Visual Fox Pro connection using ODBC error

13. Processing SQL (pro*c) errors: connection failures etc.