Connection String Question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Connection String Question

  1. #1
    Join Date
    Feb 2011
    Posts
    11

    Question Connection String Question

    How can I create a windows form to allow users to change SQL database connection string?

  2. #2
    Join Date
    Feb 2011
    Posts
    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?

  3. #3
    Join Date
    Feb 2011
    Posts
    11

    Re: Connection String Question

    My application connect locally to a sql server and the connection string is located in app.config

  4. #4
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,999

    Re: Connection String Question

    You can place it somewhere else.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Mar 2004
    Location
    3311'18.10"N 9645'20.28"W
    Posts
    1,808

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center