开发者

Using same connection string in a DataContext constructor and SqlConnection

I am preparing to deploy a web service that uses SqlConnection primarily as its means to get to the database, and I am adding some new methods that use a DataContext instead of that, and the default constructor and DBML file would use a connection string refe开发者_StackOverflow中文版ring to my development machine (I believe...)

The connection string that the SqlConnection objects use is hard coded into a separate class (don't ask). If I provide the DataContext with the same connection string as the SqlConnections will that work instead of modifying the DBML or Web.config?

The connection string that is used in these objects is:

Dim cn As New SqlClient.SqlConnection
cd.ConnectString = ApplicationInfo.ConnectString 'Connection string is stored here

So will this work too? Do I have to change something else?

Dim db As New FADataContext(ApplicationInfo.ConnectString)

Where ApplicationInfo.ConnectString is a hard coded string that has the properties of the connection. I don't have physical access to the production SQL server or Web server therefore can't use the DBML designer to edit the connection string. And they aren't stored in the .config files.


I'm pretty sure that would work. I know when you use Entity Framework you can send a connection string in the DataContext and it works fine. Although the connection string has more information in it then regualar connection strings, like the name of the csdl, msl, ssdl or whatever.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜