How can I make LINQ to SQL use a connection string which is being modified at runtime?

前端 未结 3 709
暗喜
暗喜 2021-01-18 05:31

I\'m experimenting some difficulties trying to use Connection String Builders (ADO.NET) within LINQ to SQL. Let me show you guys what I\'m trying to do:

3条回答
  •  被撕碎了的回忆
    2021-01-18 06:03

    You're forgetting to send in the connectionstring to the DataContext constructor.

    Example:

    LINQTOSQLDataClassDataContext db = new LINQTOSQLDataClassDataContext(builder.ConnectionString);
    

提交回复
热议问题