Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ado and Data Environment
Message
 
À
10/12/2001 17:14:48
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00592419
Message ID:
00593055
Vues:
16
>Hello everybody,
>I have a data environment created at design time and a connection to the data base.
>Many command are created at design time, what I want to give the possibility to the user to open another
>data base with another path.
>Please help me .
>PS. I tried to close the current connection and reopen it with other connection string, so the command in the new connection are not available
>what should I do?
>Thank you
> Robert

I just discovered that if you are using bound controls, you need to reset the DataSource property after changing the connection:
Option Explicit

Private Sub cmdConnection1_Click()
    With DataEnvironment1.Connection1
        .Close
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Data Source=C:\TEMP\New Folder\db1.mdb;" & _
                            "Persist Security Info=False"
        .Open
    End With
    DataEnvironment1.Command1
    Set DataGrid1.DataSource = DataEnvironment1
    DataGrid1.Refresh
End Sub

Private Sub cmdConnection2_Click()
    With DataEnvironment1.Connection1
        .Close
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                            "Data Source=C:\TEMP\New Folder\db2.mdb;" & _
                            "Persist Security Info=False"
        .Open
    End With
    DataEnvironment1.Command1
    Set DataGrid1.DataSource = DataEnvironment1
    DataGrid1.Refresh
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform