Hello experts, my problem: I am writing a simple database application using visual basic 2005 and MS Server Express. I am planning to export with MS Sever Express with the applicatin. The application setting of the software requre a connection string to the database. Does anyone have any example code or could ead me in the right direction so that the connection string is set automatically or is set with little input from non computer lit users.
Thank you in advance for you help. If I have not asked my question well enough, please ask.
create a Setting variable in your solution. Look at solution explorer, Properties folder, Settings item. Create there a string variable of type User. This will generate a persistent variable into your application.
ask the user to enter the connection string, or better just ask for the required elements (server name, database name, user name, password) and store it/them at the persistent/s variable/s.
build the connection by yourself using those variables, and connect the database programatically, using the SqlConnection class.
I have the similar setup. I have created a table in SQL with a field/column which stores the sql connection strings. These columns/table gets populated in a grid in the interface. the user would select the row and thereafter using the string you can do what ever is required.
Sorry, i think must not have explainined myself very well, what I want to do is build a form which will have a browse option to allow the user to locate the database and a combo box showing the server name. What I need is a way to automatically find the server name so I can store name in the combo box, so I can set up the connection string.
Similiar to the form used in the Visual Studio to attach a database to a project.