-
February 5th, 2011, 06:22 AM
#1
Connection String Question
How can I create a windows form to allow users to change SQL database connection string?
-
February 5th, 2011, 08:19 AM
#2
Re: Connection String Question
Did your windows form app connect to DB or you have local (or maybe remote) server with ASP.NET site on it, and want to users to change it's connString? Please specify where did your connection string is locate in web.config or maybe somewhere else?
-
February 5th, 2011, 11:12 AM
#3
Re: Connection String Question
My application connect locally to a sql server and the connection string is located in app.config
-
February 5th, 2011, 02:05 PM
#4
Re: Connection String Question
You can place it somewhere else.
-
February 5th, 2011, 03:45 PM
#5
Re: Connection String Question
create a simple form with an ok/cancel button and a property grid in it. give it an sqlconnectionbuilder object, and pass in your connection string (or the one you want the user to edit), and assign that to the property grid's SelectedObject property. this will let the user design the connection string without having to know all the connection string ins and outs. from there get the sql connection string builder's connection string property (after the user presses the ok button & is done editing the connection string).
create a string user setting in your windows application. this will allow you to load and save the setting. from there, anywhere in your application you can call
Code:
Settings.Default.WhateverYouCallThisSetting = TheValueOfTheUserDefinedConnectionString;
Settings.Default.Save();
and it will save it at the user level. then the next time the application is run, the connection string will be whatever the user set it to.
be careful, and make sure you restrict who can alter database connections, and have a backup reset function in case some bonehead messing things up.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|