Asked by:
PROBLEM WITH CONNECTION MYSQL

Question
-
User-665550604 posted
Hallo to everybody.
I have a problem with my first asp.net page.
-------------------------------
ERROR FROM THE ASP.NET PAGE
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)
-------------------------------
THE STRING CONNECTION IS LOCATED IN THE WEB.CONFIG FILE AND WITH ASP PAGES IT WORKS WELL.
THE CODE OF THE ASP.NET PAGE IS AS IT FOLLOWS:
-----------------------------------
<%@ Page Language="VB" MasterPageFile="~/GdlConnect.master" %>
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %>
<%@ Import NameSpace="System.Configuration" %>
<script runat="server">
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content2" contentplaceholderid="ContentPlaceHolder2" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat ="server"
SelectCommand="SELECT * FROM contenuto WHERE titolo = 'Gestionale' "
ConnectionString="<%$ ConnectionStrings:gdlconnect %>"
DataSourceMode="DataReader" onselecting="SqlDataSource1_Selecting"
/>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<%#Eval("descrizione")%>
</ItemTemplate>
</asp:DataList>
</asp:Content>
--------------------------
PLEASE HELP ME.THANK YOU
Saturday, March 3, 2012 12:40 PM
All replies
-
User-1589095703 posted
Make sure that your SQL Server instance in web.config is correct.
Saturday, March 3, 2012 1:05 PM -
User-665550604 posted
My SQL SERVER instance in web.config is as it follows:
<connectionStrings>
<add name="gdlconnect"
connectionString="server=localhost;database=XXXXXXXXX;uid=NAMEUID;password=PASSWORD" />
</connectionStrings>It's the same of my asp page. With the asp page it works.
Thank you for your help
Monday, March 5, 2012 2:51 AM -
User-1589095703 posted
Try to use { "Source=.\InstanceName;...."
Monday, March 5, 2012 4:32 AM -
User-665550604 posted
Excuse me, in this way?
<connectionStrings>
<add name="gdlconnect"
connectionString="Source=.\InstanceName;server=localhost;database=xxxxxx;uid=xxxxx;password=xxxxxx" />
</connectionStrings>Monday, March 5, 2012 7:41 AM -
User-1589095703 posted
Like this:
Data Source=.\instancename;Initial Catalog=urDataBase;User Id=Username;Password=Password;
Monday, March 5, 2012 12:29 PM