开发者

connectionstring in linq to sql

the connection string property of the dbml file is currently being read from the application settings file. in the dbml designer code it looks like this :

Global.HMIS.My.MySettings.Default.NewVersionConnectionString

if i try to edit the connection string from the properties window of the dbml file, i cannot change anything there its all read only. also if i try to edit it directly in the code file it changes every time i save. so the hell do i set the connection string property to read 开发者_开发知识库from app.config instead of settings.settings file


Add your own string to application settings and use it with DataContext(string) constructor, as recommended in the previous post. You can set it initially to connection string generated by LINQ to SQL Wizard, or select any other appropriate default value. Add Connection String editbox to the program Options dialog, allowing to change it to user.


Your data context class has a constructor that takes a connectionstring. Just read the connectionstring from app.config and use the other constructor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜