Why do simple Webparts have to make a connection to SQL Server

H

Hitesh

Hello All,

I was trying a simple piece of code is ASP.Net using Web Parts, all it does
is display a generic web part on a page. But when I try to run the code it
gave me a SQL Server Connection error which is ,
"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: Shared Memory Provider, error: 40 -
Could not open a connection to SQL Server)"

Though i am not trying to conect to the dataase at any point in the page. I
have 2 SQL Express 2008 Services running on my machine. One of it was stopped
and the other was running. The piece of code which i used to connect is
specified below.

When i started the other SQL Express services the code started working. So
my question is why and where does Web Part have to connect to the SQL
Services.


Code in the ASP.Net page
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="GenericWebPartSample.aspx.cs" Inherits="GenericWebPartSample" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Example of a Generic WebPart </title>
</head>
<body>
<form id="form1" runat="server">
<asp:WebPartManager ID="WebPartManager1" runat=server>

</asp:WebPartManager>

<div>
<asp:WebPartZone ID="MainZone" runat=server HeaderText="Main">
<ZoneTemplate>
<asp:Label ID="Label1" runat=server Title="GenericWebpart Label">
<h4>
Generic Webpart that uses a label control to generate
the contents of a web part
</h4>
</asp:Label>
</ZoneTemplate>
</asp:WebPartZone>
</div>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top