web parts and a database

G

Guest

I'm trying to add a web part to my page and when I run my page with the web
part I get this error:
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)


Now the entire web site is static and the web part has a calendar, so what
database is it trying to connect to and how can I get rid of this and so I
can run my page with the web parts?
 
S

Steven Cheng[MSFT]

Hello igotyourdotnet,

From your description, you're getting "An error has occurred while
establishing a connection to the server. ............" when try running an
ASP.NET 2.0 page whch use the webpart on it, correct?

Based on my experience, such problem is likely due to the webpart
service(personalization service)'s provider can not correctly establish
connection to the underlying database(which persist webpart data). Are you
using using customized provider setting for your personaliation
service(webpart) or use the default SqlServer provider(point to a
sqlexpress database file)? By default, all the ASP.NET 2.0 applciation
services(include membership, rolemanager, profile, personalization ...)
are using Sql provider and the connection string is pointing to a local
sqlexpress database file(in App_Data folder). You can open the
machine.config file on the server and locate the default "LocalSqlServer"
connectionstring as below:

===================
<connectionStrings>
<add name="LocalSqlServer" connectionString="data
source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
Instance=true" providerName="System.Data.SqlClient" />
==================

and the default webpart/personalization service's provider setting is in
the machine level web.config file(the same dir with machine.config) as
below:

========================
..................
<webParts>
<personalization>
<providers>
<add connectionStringName="LocalSqlServer"
name="AspNetSqlPersonalizationProvider"
type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider,
System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>

..........................
</webParts>
</system.web>

=============================

as you can see, it use the "LocalSqlServer" connectionstring by default.

Therefore, if you haven't manually change to use customized provider or
database connection, the problem here is possiblye due to the current
ASP.NET runtime fail to create connection to the default SQL Express
database file. For general troubleshooting, you can try the following
steps:

1.Create a new project and test the same things to see whether it works.
Also, you can try using other services such as membership, profiles with
the default Sql provider to see whether they can work. This can further
isolate whether the problem is specfic to all providers using the default
sql database file or just the webpart/ personalization service.

2. Are you creating and developing the web project through HTTP/IIS server
or file system/test server? When developing in IIS, the runtime use the
IIS worker process identity as security context and for IIS5, its the
machine\ASPNET, for IIS6, it's the Network Service by default. If this is
the case, you can try swtich the worker process identity to a powerful
account(such as the local system) to see whether it works. This can help
check whether the problem is due to security permission.

#Configuring ASP.NET Process Identity
http://msdn2.microsoft.com/en-us/library/dwc1xthy.aspx

3. for testing, if you have a SQL Server 2000 or SQL server 2005 database
server instance available, you can manually configure your ASP.NET
application's service to use the SQL Server 2000/2005 instance as
persistent storage. To do this you can follow the guide in the following
articles.(include change the connectionstring I mentioned above):

#Creating and Configuring the Application Services Database for SQL Server
http://msdn2.microsoft.com/en-us/library/2fx93s7w.aspx

#Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL
Server 2005
http://www.topxml.com/XML/re-13439_Configuring-ASP-NET-2-0-Application-Servi
ces-to-use-SQL-Server-2000-or-SQL-Server-2005.aspx


Hope this helps. If there is any other findings or anything unclear, please
feel free to let me know.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

so to use web parts I need the page connect to a DB? I can't just have static
web parts and no personlization for them?
 
S

Steven Cheng[MSFT]

Hello igotyourdotnet,

Thanks for your reply.

Yes, if you're using the webpart through the default SQL
provider(AspNetSqlPersonalizationProvider class), you do have to provide a
sqlserver instance or SQLEXPRESS engine.

However, as I said, the ASP.NET 2.0's application servies are all designed
as provider based, it's flexible to create custom provider and use custom
provider to replace the default ones. I've found some web articles that
mentioned creating custom provider (file based for example) to avoid using
database:

#Webparts without SqlExpress or SqlServer
Categories
http://www.kowitz.net/2006/5/2/Webparts+without+SqlExpress+or+SqlServer.aspx

You can get more information about the provider model in ASP.NET 2.0 and
developing custom provider in the MSDN dev center:

#Provider Toolkit
http://msdn.microsoft.com/asp.net/downloads/providers/default.aspx

Hope this helps.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

thanks, I'll take a look. this is my first time working with the .NET web
parts on a web app and not in a sharepoint environment.

thanks
 
S

Steven Cheng[MSFT]

Sure. If you have any further questions, please feel free to let me know.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top