View Single Post
  #1 (permalink)  
Old October 19th, 2006, 03:56 PM
VictorVictor VictorVictor is offline
Friend of Wrox
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQLServerExpress not allow remote connection

Help Please:

I'm writing a small web service and for testing am using the Northwind db. Testing fails due to the following message:

System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

The (entire) code shown below uses the Northwind db, which I have just downloaded and installed.

I cannot find a way to change the default settings for the SQL Server to allow remote connections. Anyone suggest a way that I can do that? I am using SQL 2005 Express.

The error is not the conn string. Both conn definitions above (commented out) do not work, it’s the SQL Server default settings.

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient

<WebService(Namespace:="", Description:="FTA web service")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicPr ofile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.Des ignerGenerated()> _
Public Class Customers
    Inherits System.Web.Services.WebService
    <WebMethod()> _
    Public Function GetCustomers() As DataSet
        Dim conn As SqlConnection
        Dim myDataAdapter As SqlDataAdapter
        Dim myDataSet As DataSet
        Dim cmdString As String = "SELECT * FROM Customers"
        'conn = New SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI")
        'conn = New SqlConnection("Server=localhost; uid=sa;pwd=;database=Northwind")
        myDataAdapter = New SqlDataAdapter(cmdString, conn)
        myDataSet = New DataSet
        myDataAdapter.Fill(myDataSet, "Customers")
        Return myDataSet
    End Function
End Class

Thanks, VV