473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

when I use webpart, I got sql connection error, what is wrong?

Hi there
I use vs.net 2005 with standard sql 2005 under machine\sql2005 for instant

when I create webpart, the code get from quickstart as follow:

<%@ Page Language="C#" %>
<%@ Register Src="WebPartPageMenu.ascx" TagName="WebPartPageMenu" TagPrefix="uc1" %>
<html>
<head id="Head1" runat="server">
<title>Web Part Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:WebPartManager ID="WebPartManager1" Runat="server"/>
<uc1:webpartpagemenu id="WebPartPageMenu1" runat="server"></uc1:webpartpagemenu>
</div>
<div>
<table style="width: 100%">
<tr>
<td style="width: 100px; height: 100px" valign="top" align="left">
<asp:WebPartZone ID="WebPartZone1" Runat="server">
<ZoneTemplate>
<asp:Calendar Runat="server" ID="Calendar1"/>
</ZoneTemplate>
</asp:WebPartZone>
</td>
<td style="width: 100px; height: 100px" valign="top" align="left">
<asp:WebPartZone ID="WebPartZone2" Runat="server">
</asp:WebPartZone>
</td>
<td style="width: 100px; height: 100px" valign="top" align="left">
</td>
</tr>
</table>
<br />
<asp:LoginStatus ID="LoginStatus1" Runat="server" />
</div>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------------------
<%@ Control Language="C#" ClassName="WebPartPageMenu" %>
<script runat="server">
// Use a field to reference the current WebPartManager.
WebPartManager _manager;
void Page_Init(object sender, EventArgs e)
{
Page.InitComplete += new EventHandler(InitComplete);
}
void InitComplete(object sender, System.EventArgs e)
{
_manager = WebPartManager.GetCurrentWebPartManager(Page);
String browseModeName = WebPartManager.BrowseDisplayMode.Name;
// Fill the dropdown with the names of supported display modes.
foreach (WebPartDisplayMode mode in _manager.SupportedDisplayModes)
{
String modeName = mode.Name;
// Make sure a mode is enabled before adding it.
if (mode.IsEnabled(_manager))
{
ListItem item = new ListItem(modeName , modeName);
DisplayModeDropdown.Items.Add(item);
}
}
}

// Change the page to the selected display mode.
void DisplayModeDropdown_SelectedIndexChanged(object sender,
EventArgs e)
{
String selectedMode = DisplayModeDropdown.SelectedValue;
WebPartDisplayMode mode = _manager.SupportedDisplayModes[selectedMode];
if (mode != null)
_manager.DisplayMode = mode;
}
void Page_PreRender(object sender, EventArgs e)
{
DisplayModeDropdown.SelectedValue = _manager.DisplayMode.Name;
}

</script>
<div>
<asp:DropDownList ID="DisplayModeDropdown"
runat="server"
AutoPostBack="true"
EnableViewState="false"
OnSelectedIndexChanged="DisplayModeDropdown_Select edIndexChanged" />
</div>
--------------------------------------------------------------------------------------------------------------------------------------------
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:
1.. If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
2.. If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
3.. Sql Server Express must be installed on the machine.
4.. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
how can I solve this problem? where I need to set up sql connection(I can't find it any where)? I create gradview and it is working to get data from sql 2005 with connection string

Thanks

Tony Dong
Dec 15 '05 #1
0 4303

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: J. Jespersen | last post by:
Hi people, I fiddling with webparts, and have created my own custom webpart from scratch. The webpart itself is contained in a myPart.dll I have two different sites. SiteA and SiteB. Both are...
1
by: Michael | last post by:
Hi, Is there a way to write some code to do some stuffs after a WebPart has been closed? I want to store the state of the WebPart in the user's profile so that I can determine if a particular...
0
by: arthernan | last post by:
If I separate the code into two buttons on a web page it works. One button creates the webpart and the second creates the connection. But the minute I move the connection creation code to the web...
0
by: Vaibhav Shah | last post by:
Hi, While loading a user control with IE WebControl's tree view in it, on a webpart, i am getting this error. Error: unable to load ~\UserControls\TreeViewControl.ascx Details: Parser Error:...
0
by: jademoon | last post by:
I have posted this message to the SharePoint.PortalServer group and the SharePoint.PortalServer.Development group and did receive any responses, so I suspect I was posting to the wrong groups. I...
0
by: Kieran | last post by:
I've created a few simple webparts and they work fine. I have now created a customised TreeView webpart (it is populated by a xml file description of a directory on disk). It renders okay but...
0
by: Christof Nordiek | last post by:
Hi, I want to create a WebPart, that shows a TreeView. So i created a class that derives from WebPart created an TreeView control therein and added it to the Controls collection. I also added...
2
by: skneife | last post by:
I need to create some zones in my asp page, that contains a header and a body like a webpart. How can I use a webpart for this designed without any webpart menu or connection with anything, like a...
0
by: vegetable21 | last post by:
Hi all, I've been having an issue with my webparts for some time now, i'll try and explain it as best as i can: ASP.NET website using webparts and forms authentication. Multiple custom...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.