开发者

Can't connect to SQL server on LINQ to SQL web page

On my prod server, I have 2 instances of SQL server, SQL Server 2000 is the default instance, and I have \SQLEXPRESS2008 as an additional named instance. In my web project, I need to connect to the default, SQL开发者_StackOverflow 2000 instance.

I'm using LINQ to SQL in Visual Studio 2008.

In the Server Explorer in Visual Studio, I can create a connection to the DB, see all the tables, correctly generate the LINQ to SQL classes, etc.

In Management Studio I can connect to the DB, see everything, edit, etc.

When I try and run my web project code, however, I get:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

My connection string in the web project looks like:

<add name="myConnectionString" connectionString="Data Source=myServer.com;Initial Catalog=myDB;Persist Security Info=True;User ID=sa;Password=XXXXX" providerName="System.Data.SqlClient" />

(I'm testing with the sa account out of desperation).

I have other web projects running fine and utilizing the DB, but this is the only one using the LINQ to SQL classes (if that matters)

Help appreciated

Jonathan


If the web server is the same as the SQL server, just use . as the server name; much simpler.

If the web server us not the same as the SQL server, ensure that there is line-of-sight between these servers through any firewalls etc. Also ensure that the server name resolves (in many ways, it is simpler to use the IP address in the connection string if name resolution cannot be guaranteed).


This may be the same thing that happened to me and is one of the most annoying things about LINQ to SQL. Each time you make a change to your dbml, it reverts to the connection used by the server explorer in VS. You must right-click the design surface then manually change the connection back to "myConnectionString", recompile and run.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜