Sie Ste

Sie Ste

  • NA
  • 196
  • 179k

modify linq to sql in C#

Oct 27 2012 11:07 AM
In a  C# 2010 application, I used linq to sql. I did this  so I could use the visual designer to drag the sql server 2008 r2 tables onto the designer suraface. This works fine if your development database is the same database where the production database is located.
However my problem is that I now need to move the code from my development database to a user acceptance database. The problem is the database connections are now hard coded into the applications.

Thus my questions are the following:
1. What can I do in the code so the database name is not hard coded? Do I need to modify a constuctor?
2. I would like the database connection information to be obtained from the app. config file.
Thus can you show me code on how to accomplish my goals?

Answers (3)