2 Replies - 4126 Views - Last Post: 08 February 2012 - 12:04 PM Rate Topic: -----

#1 [email protected]  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 24-January 12

in c# select sql server database based on combo box

Posted 08 February 2012 - 11:55 AM

hi,
I have a windows form with a combo box on it. The combo box has the words Production and Development in it. If the user selects "Production", I need my C# code to point to the Production database. If the user selects "Development", I need my C# code to point to the Development database. Can someone please tell me how to do this?

thanks,
Sharon
Is This A Good Question/Topic? 0
  • +

Replies To: in c# select sql server database based on combo box

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: in c# select sql server database based on combo box

Posted 08 February 2012 - 12:01 PM

Store two connection strings in your (app/web).config file. Then, when it's time to fetch data, check the selected value. If it's "Development", load the development connection string from your config file and use it to make your connections. Otherwise, load the other connection string.
Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6504
  • View blog
  • Posts: 14,355
  • Joined: 02-June 10

Re: in c# select sql server database based on combo box

Posted 08 February 2012 - 12:04 PM

What part confuses you?

How to react to a combobox.Selectionchanged event? Or how to change the value of the value of a variable? Or how to use a database?

The tutorials and articles at FAQ 20 will probably prove helpful.



TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Form1 talk to Form2



FAQ (Frequently Asked Questions - Updated Jan 2012

Spoiler


I'm going to point out that having your email address as your username is just begging for webcrawler apps to SPAM the living daylights out of you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1