0

I need write simple util, which will connect to different databases. It'll be good to use LINQ. How can I create custom connection using LINQ? For example, there'll be form with 4 textboxes: server, database name, login and password. And I need create connection string with this params.

I know how can I do it via ADO, but I need use LINQ.

P.S. LINQ to SQL.

3
  • 1
    LinqToAnythingInparticular? LinqToSQL or LinqToEntities comes to mind. Commented Sep 7, 2012 at 16:58
  • LINQ to SQL. Thanks for your remark Commented Sep 7, 2012 at 17:01
  • I'm not quite sure what you're asking, but this may be related to what you want; stackoverflow.com/questions/5068944/… Commented Sep 7, 2012 at 17:03

2 Answers 2

0

You can use the SqlConnectionStringBuilder to build a connection string from your inputs and then pass that to the constructor of your DataContext.

Sign up to request clarification or add additional context in comments.

Comments

0

The SqlConnectionStringBuilder performs checks for valid key/value pairs. Therefore, you cannot use this class to create invalid connection strings; trying to add invalid pairs will throw an exception. The class maintains a fixed collection of synonyms and can translate from a synonym to the corresponding well-known key name.

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.