开发者

Debugging vb.net execution of database function call to remote sql server

开发者 https://www.devze.com 2023-04-05 11:19 出处:网络
Working in VWD 2010 Express I have an aspx.vb file with the following connection string: Protected Function getPasswordLength() As Integer

Working in 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 producti开发者_高级运维on 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?


Make sure your SQL Server is configured to accept remote connections.

0

精彩评论

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

关注公众号