1

I am using LinqToSql. I have different databases for my application(Just database name is different). I pick url value and then use database according to that.

Problem is that there is a single .dbml file, there is one constructor where connection string is picked from web.config file. But I need to use different databases according to query string. Can we use single dbml file with more than 1 databases and how?

Is there possible solution for this?

1
  • As you'll need one database at a time, you can change database name in connection string object at runtime. Commented Nov 11, 2013 at 10:50

1 Answer 1

2

You can change database name in the connection string at runtime. Just create context object with new connection string parameter and use it for queries.

DataContext context = new DataContext (newConnectionString);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.