Sunday, March 25, 2012

connection problem

I get the following message:
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)
From the following code:
<%@. Page Language="VB" Debug="true" %>
<script runat="server">
Dim ConnectionString As String = "server=
(local);database=ASPExamples"
Dim SelectCommand As String = "SELECT CustomerID, name, phone from
customers"
Dim isEditing As Boolean = False
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(SelectCommand, myConnection)
Dim ds As New DataSet()
myCommand.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End Sub
See:
http://betav.com/blog/billva/2006/06/getting_and_staying_connected_1.html
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
------
"Roger Halls" <roghalls@.gmail.com> wrote in message
news:Xns992A7925D4244roghallsgmailcom@.198.186.190. 150...
>I get the following message:
> 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)
> From the following code:
> <%@. Page Language="VB" Debug="true" %>
> <script runat="server">
> Dim ConnectionString As String = "server=
> (local);database=ASPExamples"
> Dim SelectCommand As String = "SELECT CustomerID, name, phone from
> customers"
> Dim isEditing As Boolean = False
> Dim myConnection As New SqlConnection(ConnectionString)
> Dim myCommand As New SqlDataAdapter(SelectCommand, myConnection)
> Dim ds As New DataSet()
> myCommand.Fill(ds)
> DataGrid1.DataSource = ds
> DataGrid1.DataBind()
>
> End Sub

No comments:

Post a Comment