5 Replies - 1615 Views - Last Post: 13 April 2011 - 02:30 PM Rate Topic: -----

#1 Stefilina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 07-April 11

Database Name in a combo box for using it in app.config

Posted 12 April 2011 - 04:02 AM

Hy, I have a question...
I want for my application to select on startup the database i want...I thought about keeping my database name in a combo box and when i run my application i will select what i want...but....how can i concatenate in app.config the ConnectionString?Does anyone Know?
Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Database Name in a combo box for using it in app.config

#2 Stefilina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 07-April 11

Re: Database Name in a combo box for using it in app.config

Posted 12 April 2011 - 04:02 AM

Hy, I have a question...
I want for my application to select on startup the database i want...I thought about keeping my database name in a combo box and when i run my application i will select what i want...but....how can i concatenate in app.config the ConnectionString?Does anyone Know?
Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Database Name in a combo box for using it in app.config

Posted 12 April 2011 - 04:40 AM

You can use the ConfigurationManager for this. :)

string myConnection = ConfigurationManager.ConnectionStrings["fooConnection"].ConnectionString;



The connection has to be in the App.config file. And don't forget to add the correct reference.

<connectionStrings>
    <add name="fooConnection" ... />
</connectionStrings>


This post has been edited by Sergio Tapia: 12 April 2011 - 04:42 AM

Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Database Name in a combo box for using it in app.config

Posted 12 April 2011 - 05:08 AM

Do you want it to save the database selection for use at a later time? Or simply use that database selection at the current time. If you just want to use it now, then simply read in the connection string from the app.config, then replace the database name with the one that is chosen.
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Database Name in a combo box for using it in app.config

Posted 12 April 2011 - 05:19 AM

Please don't create duplicate threads. I have merged the threads.
Was This Post Helpful? 0
  • +
  • -

#6 Stefilina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 07-April 11

Re: Database Name in a combo box for using it in app.config

Posted 13 April 2011 - 02:30 PM

View PostSergio Tapia, on 12 April 2011 - 04:40 AM, said:

You can use the ConfigurationManager for this. :)

string myConnection = ConfigurationManager.ConnectionStrings["fooConnection"].ConnectionString;



The connection has to be in the App.config file. And don't forget to add the correct reference.

<connectionStrings>
    <add name="fooConnection" ... />
</connectionStrings>



I have the path of my connection string in my combobox using a list ..and i put more of add<"path1">...add<path2> in my app.config but now..i want when i select one path from that combobox, to use the database specified by that path..how can i do this?
Thank you in advance.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1