General discussion

Locked

Set connectionstring property at runtime

By ggardner@internet-works. ·
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?

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Set connectionstring property at runtime

by Dragon Emperor In reply to Set connectionstring prop ...

Yes, the ConnectionString property can be set at runtime. What problem are you having getting it set?

Collapse -

Set connectionstring property at runtime

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?

Collapse -

Set connectionstring property at runtime

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.

Collapse -

Set connectionstring property at runtime

This question was closed by the author

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums