468,505 Members | 1,623 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

web parts and a database

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?

Sep 26 '06 #1
5 2581
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|aspn etdb.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.SqlPerson alizationProvider,
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_C...lication-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/subscripti...ult.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/subscripti...t/default.aspx.

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

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


Sep 27 '06 #2
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?

"Steven Cheng[MSFT]" wrote:
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|aspn etdb.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.SqlPerson alizationProvider,
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_C...lication-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/subscripti...ult.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/subscripti...t/default.aspx.

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

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


Sep 27 '06 #3
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/Webpa...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/do...s/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.
Sep 27 '06 #4
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

"Steven Cheng[MSFT]" wrote:
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/Webpa...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/do...s/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.
Sep 27 '06 #5
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.

Sep 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by weboweb | last post: by
18 posts views Thread by =?Utf-8?B?Q2hhcmxlc0E=?= | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.