Discussion Locked

Set connectionstring property at runtime

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is it possible to set the connectionstring property of an ADO data control at runtime? I am writing an app and want to be able to allow the user to specify the where the database is stored on the hard drive. So the connectionstring property must be set at runtime as I read it in from a .ini file. Any ideas?

4 replies

by ggardner

On form load I run

datPrimaryRS.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & DB_Path & "sei.mdb;"--DB_Path holds the path to the database (and it is correct at runtime).

This changes the connection string alright, but the data from the new database doesn't show up on the form. The form continues to show the data from the database specified in the connectionstring property during development.

Do I need to do something to refresh the recordset or something?

by ggardner

I figured it out! I have to set the recordsource again then do a refresh on the data control. If this is not right or there is a better way, let me know. Thanks.

This discussion is closed to new replies.