Problem changing DataEnvironment to point to new SQL Server Database 
Author Message
 Problem changing DataEnvironment to point to new SQL Server Database

I have a vb 6 app that works against a SQL Server 7 database.  I am using
the dataenvironment to define all of my sql and I have the following in my
DataEnvironment:
    -    DataEnvironment1
    --            ConnectionSQLServer (points to database1)
    ---                    SelectAccounts (a sql statement that uses
ConnectionSQLServer
                                                         to select * from
Accounts)

In my code the user can choose the database they want to use when logging
in.  I am having a problem trying to switch to database2 if the user enters
it.  My connection remains to database1.  I am doing it in my vb 6 code as
follows:

Dim DE1 as NEW DataEnvironment1

With DE1.ConnectionSQLServer
        .Properties("Data Source") = "Server"
        .Properties("User ID") = "sa"
        .Properties("Password") = "sa_pwd"
        .Properties("Initial Catalog") = "database2"
        .Properties("Current Catalog") = "database2"

        .open
End With

DE1.SelectAccounts

When I go to DE1.rsSelectAccounts I am still getting info from database1.
Am I doing something wrong?

Thanks,
Dave



Sun, 07 Jul 2002 03:00:00 GMT  
 Problem changing DataEnvironment to point to new SQL Server Database
Just a thought, but why don't you try setting DE1= Nothing before opening
the second connection, that should at least force it to close the original
one.


Quote:
> I have a vb 6 app that works against a SQL Server 7 database.  I am using
> the dataenvironment to define all of my sql and I have the following in my
> DataEnvironment:
>     -    DataEnvironment1
>     --            ConnectionSQLServer (points to database1)
>     ---                    SelectAccounts (a sql statement that uses
> ConnectionSQLServer
>                                                          to select * from
> Accounts)

> In my code the user can choose the database they want to use when logging
> in.  I am having a problem trying to switch to database2 if the user
enters
> it.  My connection remains to database1.  I am doing it in my vb 6 code as
> follows:

> Dim DE1 as NEW DataEnvironment1

> With DE1.ConnectionSQLServer
>         .Properties("Data Source") = "Server"
>         .Properties("User ID") = "sa"
>         .Properties("Password") = "sa_pwd"
>         .Properties("Initial Catalog") = "database2"
>         .Properties("Current Catalog") = "database2"

>         .open
> End With

> DE1.SelectAccounts

> When I go to DE1.rsSelectAccounts I am still getting info from database1.
> Am I doing something wrong?

> Thanks,
> Dave



Mon, 08 Jul 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Remote Data Control--Problems with Adding new Record to SQL Server 6.0 Database

2. Dynamic change Sql Server Database

3. CR 8.0 with MS SQL Server - database changing

4. Changing SQL Server Databases

5. How to pass a new SQL query using the DATAEnvironment

6. Problem adding new record using SQL Server

7. Problem with ADO and SQl Server on adding a new record in a table

8. VB Sql Server Via ADO Problem: [Microsoft][ODBC Sql Server Driver]

9. Problem adding new record to SQL database recordset

10. DataEnvironment SQL change at run time

11. Dataenvironment and SQL server slow

12. DataEnvironment changing SQL From code

 

 
Powered by phpBB® Forum Software