Programming in vb.net: Debugging vb.net connection to remote sql server on newest questions tagged vb.net – Stack Overflow
VWD 2010 Express
I have an aspx.vb file with the following connection string:
Protected Function getPasswordLength() As Integer Dim conn As New SqlConnection("Data Source=localhost;database=MyDB;Integrated Security=true") Dim cmd As SqlCommand = conn.CreateCommand() cmd.CommandText = "select dbo.getPWLen() ;" conn.Open() getPasswordLength = CInt(cmd.ExecuteScalar()) conn.Close() End Function
This works when the code is on the web server / which is collocated with the SQLServer.
However, when I want to debug, I have to copy to the server. I would like to be able to “debug in place” on my development machine and only copy files to the production machine periodically. Technically the production machine is not in production at the moment, but that’s beside the point.
Anyway, I followed the following instruction: http://weblogs.asp.net/nannettethacker/archive/2008/02/17/creating-a-database-connection-to-a-remote-sql-server-database-within-visual-web-developer.aspx
I can now see the remote database, functions, etc. on the other machine (from the VWD running on the development machine).
However, I thought I should then be able to execute this same code locally on the development machine using ctrl-F5, but I get the following error:
**Server Error in ‘/’ Application.
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)**
Should what I’m doing be possible? If so, any ideas what I’m doing wrong?
Programming in vb.net: programming-in-vb-net