webservices, database reading - confused

GeX

GeX

Soldato
Joined
17 Dec 2002
Posts
6,982
Location
Manchester
hmm..

trying to create a webservice to connect to a database.


Code:
    <WebMethod()> Public Function GetAttractions(ByVal AttractionID As String) As DataSet
        Dim dsn As String = "server=<localhost>;database=<Database>;"
        Dim myconnection As SqlConnection = New SqlConnection(dsn)
        Dim mycommand As SqlDataAdapter = New SqlDataAdapter("select * from attraction where AttractionID='" & AttractionID & "' order by Name", myconnection)

        Dim ds As New DataSet()
        mycommand.Fill(ds, "attractions")
        Return ds
    End Function

and i'm getting a lovely error;

Code:
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)
 
Last edited:
Back
Top Bottom