Thursday, November 11, 2010

How can I configure the connection string of a VB project in runtime?

I am using the latest version of Visual Studio, programming in Visual Basic I can configure the Data Source in the Data Sources tab where the solution Explorer is, Then I can use the data with no problems.



But I need to publish the project and install it on the client's computer, for which it needs to use a different connection string particulary to connect to the correct server and authenticate the user.



How can this be done?How can I configure the connection string of a VB project in runtime?
It depends on where the information is coming from. Pop up a form, asking the user for the server, user and login, read it from a text file, read it from the registry (write a little utility to write it to the registry when you install it), etc. Then read the information at runtime and use that to build the connection string. (It's a lot easier if you forget the controls, and just do the connection in pure code.)How can I configure the connection string of a VB project in runtime?
It depends highly on the data source.

http://www.connectionstrings.com/



Generally, you use the System.data.Odbc data and do:



String connString = ...ConnectionString...

OdbcConnection conn = new OdbcConnection(connString);

No comments:

Post a Comment