Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

One question I’ve seen asked a few times by people over the last few weeks is “how do I setup the new ASP.NET Membership, Role Management, and Personalization services to use a regular SQL Server instead of SQL Express?” This blog entry walks you though a few simple steps on how to-do this.

 

Quick Review: What are the new ASP.NET 2.0 Application Services?

 

ASP.NET 2.0 includes a number of built-in “building block” application services.  We call them “building blocks” because they are useful core frameworks for enabling super-common scenarios with web applications today – and as a result can provide significant productivity wins and time-savings for developers.

 

They include: a membership API for managing usernames/passwords and secure credential management, a roles API that supports mapping users into logical groups, a profile API for storing arbitrary properties about both authenticated and anonymous users visiting a web site (for example: their zipcode, gender, theme preference, etc), a personalization API for storing control customization preferences (this is most often used with the WebPart features in ASP.NET 2.0), a health monitoring API that can track and collect information about the running state and any errors that occur within a web application, and a site navigation API for defining hierarchy within an application and constructing navigation UI (menus, treeviews, bread-crumbs) that can be context specific based on where the current incoming user is in the site.

 

The ASP.NET Application Service APIs are designed to be pluggable and implementation agnostic, which means that the APIs do not hardcode the details of where data is stored with them.  Instead, the APIs call into “providers”, which are classes that implement a specific “provider contract” – which is defined as an abstract class with a defined set of methods/properties that the API expects to be implemented.

 

ASP.NET 2.0 ships with a number of built-in providers including: a SQL Express provider for going against local SQL Express Databases, SQL 2000/2005 providers that work against full-blown SQL Servers, an Active Directory Provider that can go against AD or ADAM implementations, and in the case of site navigation an XML provider that can bind against XML files on the file-system.

 

The beauty of the model is that if you don’t like the existing providers that ship in the box, or want to integrate these APIs against existing data-stores you are already using, then you can just implement a provider and plug it in.  For example: you might already have an existing database storing usernames/passwords, or an existing LDAP system you need to integrate with.  Just implement the MembershipProvider contract as a class and register it in your application’s web.config file (details below), and all calls to the Membership API in ASP.NET will delegate to your code.

 

Default SQL Express Providers

 

Out of the box, most of the ASP.NET 2.0 application services are configured to use the built-in SQL Express provider.  This provider will automatically create and provision a new database for you the first time you use one of these application services, and provides a pretty easy way to get started without a lot of setup hassles (just have SQL Express on the box and you are good to go).  Note that SQL Express databases can also be upgraded to run in the context of full-blown SQL Server instances – so apps built using SQL Express for development can easily be upgraded into a high-volume, clustered, fail-over secure 8P SQL box when your app becomes wildly successful.

 

How do I change the providers to use SQL Server Instead of SQL Express?

 

If you want to use a full-blown SQL Server 2000 or SQL Server 2005 database instance instead of SQL Express, you can follow the below steps:

 

Step 1: Create or obtain a blank SQL database instance

 

In this step you’ll want to create or obtain a connection string to a standard SQL database instance that is empty.

 

Step 2: Provision your SQL database with the ASP.NET schemas

 

Open a command-line window on your system and run the aspnet_regsql.exe utility that is installed with ASP.NET 2.0 in under your C:\WINDOWS\Microsoft.NET\Framework\v2.0.xyz directory. 

 

Note that this utility can be run in either a GUI based mode or with command-line switches (just add a -? flag to see all switch options).

 

Using this wizard you can walkthrough creating the schema, tables and sprocs for the built-in SQL providers that come with ASP.NET 2.0.  The below screens show the step-by-step walkthrough of this:

 











 

Once you have finished walking through the wizard, all the database schema + sprocs to support the application services will have been installed and configured (note: if your DBA wants to see exactly what is going on behind the covers, we also ship the raw .sql files underneath the above framework directory, and your DBA can walkthrough them and/or run them manually to install the DB).

 

Step 3: Point your web.config file at the new SQL Database

 

ASP.NET 2.0 now supports a new section in your web.config file called “<connectionStrings>” which (not too surprisingly) are used to store connection strings.  One nice thing from an administration perspective is that the new ASP.NET Admin MMC Snap-in now provides a GUI based way to configure and manage these:





ASP.NET 2.0 also now supports encrypting any section stored in web.config files -- so you can also now securely store private data like connectionstrings without having to write any encryption code of your own. 

 

ASP.NET 2.0 ships with a built-in connection string called “LocalSqlServer” which by default is configured to use a SQL Express database, and which by default the Membership, Roles, Personalization, Profile and Health Monitoring services are configured to use.

 

The easiest way to have your application automatically take advantage of your newly created SQL database is to just replace the connectionstring value of this “LocalSqlServer” setting in your app’s local web.config.

 

For example, if I created my database on the local machine in an “appservicesdb” database instance and was connecting using Windows Integrated security, I would change my local web.config file to specify this:

 

<configuration>

 

    <connectionStrings>

        <remove name=”LocalSqlServer”/>

        <add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=appservicesdb;Integrated Security=True" providerName="System.Data.SqlClient"/>

    </connectionStrings>

 

</configuration>

 

Hit save, and all of the built-in application services are now using your newly created and defined SQL Server database.

 

Note: The one downside with the above approach is that I’m re-using the “LocalSqlServer” connection string name – which will feel weird if/when I deploy my database on another machine.  If I wanted to name it with my own connection string name, I could do this simply by adding a completely new connection-string, and then pointing the existing providers to use the new connection-string name in place of the default LocalSqlServer one. 

 

Hope this helps,

 

Scott

 

P.S. In some future blog post I’ll walkthrough actually using some of the above new APIs.

Published Thursday, August 25, 2005 4:17 PM by ScottGu

Comments

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 26, 2005 2:51 AM by Jeff Turner
A few months ago this post http://kinnie.blogspot.com/2005/05/personalization-web-parts-in-aspnet-20.html about personalization (Web Parts) helped me out! Changes were made to the machine.config ...

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 26, 2005 3:31 AM by Hannes Preishuber
also the accessmembership provider is now available, with soucre code in the provider tool kit
http://msdn.microsoft.com/asp.net/beta2/providers/default.aspx

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 26, 2005 12:11 PM by Eric Newton
So whatever happened to the admin tool that can configure these things, lost from beta 1?

Being able to modify the membership/roles via the web interface (or any other) is tantamount to using the built-in aspnet providers...

So, it would be cool to see some comments on how to re-enable that tool, and what tools are available (webadmin.axd, an exe too perhaps?, aspnet iis mmc plugin?) :-)

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 26, 2005 1:12 PM by scottgu
Hi Eric,

You can use the MMC Admin tool to manage all of the provider settings.

You can then manage members/roles using the web admin tool (create/delete users, create and manage role groupings, etc). Note that the web admin tool will work with any provider -- so if you build your own custom provider you can point it at that and manage your settings that way too.

To pull up the web admin tool click the "ASP.NET Configuration" item in the "WebSite" menu. To pull up the MMC admin tool, just launch the IIS admin tool (inetmgr) and click the ASP.NET tab and then "edit configuration" for whatever app you want to manage.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Saturday, August 27, 2005 3:58 PM by Israel Aece
Hello Scott,

Please, why inside of the Visual Studio .NET we don't have items of the menu to have access these utilities (as aspnet_regsql.exe) or UI (User Interface), like Enterprise Library, for center these utilities?

Regards,

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, August 29, 2005 4:47 AM by nice.
Nice. Thanks for that, this was just the getting started guide I was looking for!

And Israel, that's the great thing about VS, if there isn't already a menu item, you can add one!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Sunday, May 28, 2006 5:06 AM by ChrisS
Scott,

You mention pointing the web admin tool at your own custom providers but you didn't say how to get the web admin tool to see the custom providers.  Can you elaborate?

Thank you.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, May 29, 2006 5:56 PM by ScottGu
Hi Chris,

The Web Admin Tool uses the configured providers in the web.config file to provide an admin experience against.  So if you register things the way I described above, the web admin tool will automatically work against your remote provider.

Hope this helps,

Scott

# I can not run ASP.NET Configuration

Tuesday, May 30, 2006 6:02 AM by Cube
When i click ASP.NET Configuration on my website in VS 2005, system open page
http://localhost:3631/asp.netwebadminfiles/default.aspx
and result is:

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

This problem is related to "Configuring ASP.NET 2.0 Application Services", is not?
Who can help me?
Thanks alot!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, May 30, 2006 10:44 AM by ScottGu
Hi Cube,

That seems a little odd.  Does your app usually run ok (when not using the web admin tool)?  

Are you running any code in Session_Start that is storing information in the Session object?

Thanks,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, May 30, 2006 1:30 PM by Joe Shiebler
How do you set up web pages so that the connection strings on each page are updated whenever the connection string name in the web.config file is changed? When a VWD project is hosted the database is usually on a different machine than the web pages. Before the site is uploaded to the host the strings must be changed to work in the new environ. So how to toggle between the local env and the hosted environment? Thanks,
Joe S.   joeshiebler@yahoo.com

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, May 31, 2006 2:29 AM by ScottGu
Hi Joe,

If you update the connection string within the web.config file, then any page accessing it via the connection string syntax will automatically pull the new value the next time a request comes in.  That means you can update the setting in one place and have it apply for the entire app.

Hope this helps,

Scott

# ASP.NET 2.0 Personalization and Membership under Windows Vista

Wednesday, May 31, 2006 3:16 AM by Ozzie Rules Blogging
If you have issues getting&amp;nbsp;Asp.net 2.0 membership and personalization running under Vista then you...

# A detailed walk through setting up the ASP.NET providers

Wednesday, May 31, 2006 11:20 AM by Robert Seder
This is a pretty excrutiating walk-through of how to use the default membership, role and profile provider...

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, June 06, 2006 1:36 PM by Rob
Hi, sorry, can I ask a dumb question:
I have a table in my SQL 2000 db which has username/password of my users. I have gone through the walkthrough and pointed the web.config to the SQL2000 db rather than the default LocalSQLServer stuff.

So my beginners question is, at what point and where do I specify which table it is that actually holds my user info and tell .net how to correctly interpret the columns as username and password etc.

Cheers for any further insights.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, June 07, 2006 10:47 AM by ScottGu
Hi Rob,

When you specify the connection string for your SQL 2000 database, you are specifying the "Initial Catalog" name -- which is the database within SQL to use (for example: if you installed your membership tables in the "foo" database within a server you'd set the value to this).

The SQL Membership provider then looks for the aspnet_membership table for the credentials.  If you want to change this, you can modify the Provider being used.  All of the built-in ASP.NET providers are now available as source downloads -- so you have full flexibility in customizing them.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, June 08, 2006 4:55 AM by Mukesh
yes this nice but I have one problem whem used connection string name "LocalSqlServer" then work fine but when I changed name of this connetion string then I got error. My connection string is connected to Sqlserver 2000 on remote machine.Can you tell me how to change connection string name?

Thanks

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, June 08, 2006 12:43 PM by ScottGu
Hi Mukesh,

In the article above I have a sample that shows how to remove and point the LocalSqlServer connection string at a remote host.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, June 09, 2006 3:39 AM by Mukesh
Hi Scott

Thanks for replying me but I can't solve my erroor yet. this is my web.config file

 <connectionStrings>
   <remove name="LocalSqlServer"/>
 
  <add name="Cn" connectionString="Data   Source=Applications;Initial Catalog=tmpDatabase;Persist Security Info=True;User ID=mac;Password=" providerName="System.Data.SqlClient"/>
</connectionStrings>

but when i used connection name LocalSqlServer instead of Cn then work fine .

please help  me how to done this...

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, June 09, 2006 11:32 AM by Mukund
Hi...

I have two role -admin,user how to set a web.config file for allow to admin role users to access admin folder web pages and user role users can access user folder??

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Saturday, June 10, 2006 11:55 AM by ScottGu
Hi Mukund,

What you'd want to-do is to use the <location> feature in web.config to control the paths for your allow/deny tags.

For example, the below web.config entry would allow admins access to the "admin" sub-directory, and deny everyone else:

<location path="admin">
  <system.web>
     <authorization>
         <allow roles="admin"/>
         <deny users="*"/>
     </authorization>
  </system.web>
</location>

You could add a similar directive for the users directory as well.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Sunday, June 11, 2006 12:56 PM by ScottGu
Hi Mukesh,

By default the providers in ASP.NET are configured out of the box to go against the "LocalSqlServer" connection-string.

You can change this for each provider if you want to (you can lookup the schema for each provider in the web.config file).  Alternatively, the simplest way to enable this is to just change the "LocalSqlServer" connection value - in which case you don't need to change anything else.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, June 12, 2006 3:17 AM by Mukund
Thanks for reply and help me.....


Mukund

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, June 12, 2006 3:18 AM by Mukesh
Hi Scott

Thanks for reply and help me..


Mukesh.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, June 15, 2006 8:36 PM by mpfaff
Hey Scott, I have one for ya.  I use VWD 05 to design a site.  I use a hosting provider through another company.  The hosting company allows usage of a SQL Server under ASP.NET 2.0 runtime.  In VWD the website worked fine.  As soon as I loaded it, I continued to get an error saying "remote SQL server does not allow remote connections".  I have tried everything I know.  ANy ideas?  Here is my connection string:

<connectionStrings>
   <add name="Personal" connectionString="Data Source=whsql-v02.prod.mesa1.secureserver.net;Initial Catalog=DB_68408;User ID=******;Password='*******';" providerName="System.Data.SqlClient"/>
            </connectionStrings>

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, June 16, 2006 1:04 PM by J. Hemenway
Thanks for the great tutorial Scott! I was wondering though how to use your own information with the Login controls like instead of a User Name and Password, I could use an order ID for the "user name" and an email address for the "password" in a reorder system I'm working on for my website. I tried originally to import the information directly into the database but it kept crashing every time I tried. Thanks for your help in advance!

# ASP.NET 2.0 Membership, Roles, Forms Authentication, and Security Resources

Tuesday, June 20, 2006 3:40 AM by ScottGu's Blog
I usually try and spend at least an hour or two each night hanging out on the ASP.NET Forums answering...

# ASP.NET 2.0 Membership, Roles, Forms Authentication, and Security Resources

Wednesday, July 05, 2006 3:52 AM by monkeyliu19801029

因为导师要个网站的项目, 我又对ASP.NET也蛮感兴趣的,毕竟未来是网络的时代。 看了乱七八糟的书后,开始专门争对自己负责的登陆模块有目的的学习了..... 这是在ASP.NET官方网站发现的最好的ScottGu的Blog, 以后陆续专贴的文章只是为了记录我的学习历程

# Membership, and the dfault database

Friday, July 14, 2006 6:49 PM by Granville Barnett

Many people when using Visual Studio 2005 require some form of authentication, membership etc but by...

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, August 01, 2006 4:30 AM by Jules
hi, i have tried this method and it works very well. however i have a problem. the connectionstring that i now use is "LocalSqlServer" how can i do to use my old connectionstring for exple "MyConnection" without having to update every single datasource object. thanks

# ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas

Tuesday, August 01, 2006 11:55 AM by ScottGu's Blog

This page lists some of the more popular &amp;ldquo;ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas&amp;rdquo;

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, August 01, 2006 3:08 PM by Xiaohong Liu
This is really helps, thanks a lot!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 02, 2006 1:56 AM by ScottGu

Hi Jules,

If you want to change your connection-string name, you'll want to re-register your membership, roles and profile providers to use a new connection-string.  You can then name this whatever you want.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Saturday, August 05, 2006 12:30 AM by Mike
In step one stated create a blank instance.. What exactly it means Can someone please explain how to setup step 1. I know how to get in the wizard and setup the rest thanks Mike

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Saturday, August 05, 2006 11:58 AM by ScottGu

Hi Mike,

To create the blank database instance you'll want to create a new Database within SQL Server.  You should be able to find a "Create Database" menu item somewhere within your SQL admin tool (the location is slightly different between SQL 2000 and SQL 2005).  You can then name the database whatever you want, and point the wizard at it.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, August 07, 2006 11:06 PM by Jim Buchan
Hay mpfaff it appears to me you are using GoDaddy? I am too and having the same problem. Have you got it figured out yet? I would like to visit with you about a solution if you have one. Thanks in advance. Jim B. jlbuchan@cox.net

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 09, 2006 4:54 AM by Tristan Smith
Hi Scott I've followed the advice above, my sqlserver 2000 database has been populated with tables and the Web Site Administration Tool Provider Test returns a successful connection. I can use the Add Roles and Manage Roles and I can Manage users but I can't Create users or use the Security Setup Wizard. Clicking on either returns 'An error was encountered. Please return to the previous page and try again.' I used the aspnet_regsql wizard and set it up as a sql db admin user. I added this to in the application's web.config: Any ideas?

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 09, 2006 8:45 PM by brunedito
Hi! I have a problem setting this. I do not use SQL server but SQL Express (not app_data dir, but instance). I also use ASP.NET development server (not IIS). Problem I have is security - when I go to asp.net configuration and then security, I'm getting this message "There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store. The following message may help in diagnosing the problem: Cannot open database "ASPappData" requested by the login. The login failed. Login failed for user 'PC\Bruno'." Since I've done everything said right, and my ASPappData is created as stated above ('PC\Bruno' is administrator windows account under which app is running), I can only blame permissions. Any solutions on that?

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 11, 2006 2:33 AM by ScottGu

Hi Brunedito,

It could be that you installed a named instance of SQLExpress on your machine.  Could that be the problem?

Also -- have you tried creating a blank SQL Express database and accessing it to see if that works?

Thanks,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 11, 2006 2:37 AM by ScottGu

Hi Tristan,

Is your application configured to use Forms based authentication or Windows authentication?

Thanks,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 11, 2006 11:06 AM by Tristan Smith

Hi Scott,

It's set to use Forms based authentication. I have tried making it windows authenticated, it makes no difference, the security setup wizard still throws An Error was encountered

I've manually created an admin account in code and it appears within the Admin Tool, I can modify the settings of the user.

My current user name on the home screen is my machine login and domain. Would the location of the project have any bearing? I've got it in My Documents/Visual Studio 2005/WebSites/Sharp-Test.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, August 14, 2006 1:14 PM by ScottGu

Hi Tristan,

Can you send me an email with your web.config file?  I can then help figure out what is going on here.

Thx!

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 16, 2006 12:37 PM by Prasad
Hi Scott, Thanks for the post. I've been blowing up my head since yesterday trying to figure out how to deploy aspnetdb.mdf that is in app_data directory to my production server. This post not only proved me that I am stupid but also saved my time in creating an aspnetdb dB in my SQLServer2000. Thanks again.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 18, 2006 8:27 PM by Chris
Hello Scott, I've been trying to configure my provider so that I can have everything stored in a sql server outside my machine. I ran the aspnet_regsql.exe and it appeared that everything worked. I looked in my database and all the new tables were created, but then when I started adding new roles and members and whatnot nothing appeared in the new tables that were created in my sql server. It appears it's still storing everything in sql express? How come it's not storing everything on the server? When I open the WAT tool and click on the provider tab it doesnt give me the option to change the provider. Do you know what the problem could be? Thanks! Chris

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Sunday, August 20, 2006 3:05 AM by micky ng
Hi all, I am trying login to the state database (ASPstate) with my domain userid, using command : "aspnet_regsql.exe -U domain\userid -ssadd", but always fail. but if i use sqlserver userid, it will success to login. any one can help? thanks

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, August 21, 2006 4:20 PM by David
I get 'An error was encountered. Please return to the previous page and try again.' when I try to access the page :S

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, August 22, 2006 4:39 PM by Boss
Many thanks.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 23, 2006 12:46 PM by Mukul
Following are my issues, Please Help. I have also posted this question in forums but unable to fix it. ************************************************************************** Scenario1: I was creating website on file system(c Drive) and now I have decided to move it on to local web server on my machine. The database has been created using aspnet_reqsql on to another development machine. Question: What configuration I need to change from my local setting to be able to access database on another server and the website is sitting on my local machine. ************************************************************************** Scenario2: I copied this site on to a new Windows 2000 machine and i have also installed database locally, .Net framework 2.0. My web.config localsqlserver connection string has changed similar to the ones that i created in scenario1 (editing the asp.net configuration from inetmgr). Question: I am getting this error : "Your login attempt was not successful. Please try again." Please let me know in scenario2, what configuration I need to create so as to be able to correct this problem. ************************************************************************** Thanks, Mukul

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 23, 2006 5:57 PM by Kenny
The images appear to me missing. The first time I visited I saw them, and now that I'm back to actually do this they are gone :)

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 23, 2006 6:01 PM by ScottGu

Hi Kenny,

The images are there for me right now (I assume you mean the images in the blog post above).  Can you check again -- or maybe you are having a proxy/connection issue?

Thanks,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 23, 2006 6:58 PM by Dusty
Hi Scott, I am having a problem with my custom membership provider that I have created for a site that I have developed. I am using SQLEXPRESS(on a remote server) and I created a membership database using the aspnet_regsql.exe utility. I added my connectionstrings in the web.config file. I made sure that my membershipprovider and roleprovider has the same applicationname. When I run the application under VS 2005, I am able to login just fine with the users I created under the ASP.NET Configuration tool. However, when I deploy the application, I am unable to login with any of the users I have created. Any suggestions? Thanks, Dusty

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, August 23, 2006 11:47 PM by Mike Peck
Scott, Great site! Your site has been a great help. I've been coding in C# Windows Forms for about 2 years, and have decided to learn web development. I downloaded VWD Express & SQL Server Express. I created a new personal web site, from the starter kit, and without too much trouble, got it up and running. My dilema: My hosting company uses SQL Server 2005 on a separate machine from the web server (which supports ASP.NET 2.0). I haven't been able to get the site running on the production server, which unfortunately is not configured for debugging (I use webhostasp.com), so all I get is the standard "Server Error in / Application." I do have a user with permissions on the database server, which I am able to connect to with SQL Server Management Studio Express. I have run aspnet_regsql on it to create the application services tables in my database, along with running the personal-add.sql file, in order to create the applications tables. My web.config connectionstrings section is, currently: I know this isn't secure, I'll take care of that after I get it working. I have tried many different variations to no avail. I would appreciate any help you could offer. Thanks, Mike.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, August 24, 2006 12:39 PM by Kenny
Ahh I figured it out. It seems my company content filter blocked your page www.scottgu.com as 'Society and Lifestyle'. Haha, defeated by my own weapon ;) Thanks Scott!!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, August 24, 2006 2:48 PM by Kenny
Great I got the images working but I am heavily confused... I was using SqlExpress. I would go to the ASP.NET Configuration and it would automatically create a aspnetdb.mdf file in the App_Data folder of my project. How can I get this functionality using SqlServer 2005 (full blown)? Instead of pointing to an actual DB in my default instance of 2005, I would really like it to create the ASPNETDB.mdf files in my App_Data folder again, but use full blown 2005 sql. That way my connection string can look like this: That way the db will carry with the project when I move it to our production server (which is also running a local default instance of SQL2005 full blown). Does that make sense? Thanks!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, August 25, 2006 8:13 PM by ScottGu

Hi Kenny,

To use full-blown SQL 2005 (rather than SQL Express), you'll want to use the step in the article above to create a SQL 2005 database and point the app at it.  Unfortunately there isn't a way to have SQL 2005 use the SQL Express database in the /app_data folder.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Saturday, August 26, 2006 3:10 AM by ScottGu

Hi Dusty,

I'm pretty sure the issue you are running into above is the application name isn't set correctly.  This blog post describes the issue and how to fix it: http://weblogs.asp.net/scottgu/archive/2006/04/22/Always-set-the-_2200_applicationName_2200_-property-when-configuring-ASP.NET-2.0-Membership-and-other-Providers.aspx

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Saturday, August 26, 2006 3:12 AM by ScottGu

Hi Mike,

This blog post describes a way you can get more detailed error messages even when remotely: http://weblogs.asp.net/scottgu/archive/2006/08/12/Tip_2F00_Trick_3A00_-Show-Detailed-Error-Messages-to-Developers.aspx

You could skip the Roles check for the moment just to see what the error is.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, August 28, 2006 12:09 PM by Kenny
Thanks Scott! I got the database setup in Sql Server 2005 successfully, and the application works great... but when I go to setup my Roles I get this lengthy error msg: Unable to connect to SQL Server database. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_manageallroles_aspx.BindGrid() at ASP.security_roles_manageallroles_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Have you ever seen this before? Also my asp.net configuration tool runs really slow after running aspnet_regsql tool and creating the database for this application. Thanks for all your help thus far! Its been very resourceful!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, August 28, 2006 10:40 PM by Vasu
we are group of student we want web hosting facility on ur server plz provide us ur monthly rates and conditions. and we r in New zealand. thanx

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, August 29, 2006 12:11 AM by ScottGu

Hi Vasu,

If you can send me email (scottgu@microsoft.com) I will try and connect you up with a hoster in NZ.

Thanks,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, August 29, 2006 12:28 AM by ScottGu

Hi Kenny,

Do you have the connection strings setup correctly for your membership and roles setup?  What you are describing sounds like you might not have these set correctly.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, August 29, 2006 9:57 AM by Kenny
Scott, I actually figured it out! Instead of explaining it all over again, you can browse over this post: http://forums.asp.net/thread/1381120.aspx Thanks for everything!!!! This blog entry has really helped solve many of my issues!! Keep up the great work!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, August 31, 2006 3:37 AM by krans001

hi scott,

I have made it work

thanks very much

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, August 31, 2006 5:30 AM by Jeewai
Thanks so much Scott for this great article! OK, I have followed steps by steps your advices to modify my app to run on SQl 2000 instead of SQL 2005 Exp. Well locally using VWD the application runs fine and is able to connect to the remote company's server to authenticate users (the newly created tables...aspnet_member and so on... in the webserver db are getting the credentials I've set up using the asp.net web admin tool) BUT I invariantly get the same error when I try to access the app from the web (the login page), after uploading the app onto the company's webserver: ------------------------------------------------ Server Error in '/newmedical' Application. Procedure 'aspnet_Membership_GetPasswordWithFormat' expects parameter '@UpdateLastLoginActivityDate', which was not supplied. 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. Exception Details: System.Data.SqlClient.SqlException: Procedure 'aspnet_Membership_GetPasswordWithFormat' expects parameter '@UpdateLastLoginActivityDate', which was not supplied. ------------------------------------------------ Any suggestions? Thanks in advance Jeewai

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, August 31, 2006 10:28 PM by ScottGu

Hi Jeewai,

The issue is almost that your database is using a Beta version of the database schema.  You'll want/need to recreate the schema using the final ASP.NET 2.0 release database schemas for it to work.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, September 04, 2006 2:47 AM by Geoff B
Hi Scott, I'm getting the same error as Tristan when trying to create a new user - "An error was encountered. Please return to the previous page and try again." I am running LocalSQLServer under SQL2005 and another data file under SQLExpress. I originally has the connection configured to use a Trusted Connection, but have changed it to use login and password. Were you able to figure out what the problem is?

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, September 05, 2006 2:20 AM by ScottGu

Hi Geoff,

If you want to send me an email with more details about the error you are seeing (along with your web.config file), I can help debug it with you.  My email address is: scottgu@microsoft.com

Thanks,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, September 06, 2006 10:47 PM by Geoff B
Thanks very much Scott for the offer. Someone suggested that I create a page to enter new users, which I did and successfully created my users. Everything else works in the WAT and I have wasted too much time already, so I won't bother trying to get this to work.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, September 07, 2006 3:23 AM by Angus
Hi Scott I configured my app's providers to use SQL Server 2000 instead of SQL Express, as in your article. My app works fine using my local database, but when I change the connection string and use an identical database on the network, I get the following error when my app tries to access the database: "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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" My sql server 2000 has named pipes and tcp/ip protocols enabled and allows remote connections. I am not using sql server 2005 at all. I can access the database fine through enterprise manager and query analyzer. Any ideas ? Thanks so much for all your help. Angus

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, September 07, 2006 4:16 AM by ScottGu

Hi Angus,

I suspect the problem might be with the connection string you are using, and specifically the security account you are connecting with.  Are you using windows integrated security to connect?  If so, then you might want to read this article to learn more about how Windows handles multiple-hops in this scenario: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000008.asp

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Friday, September 08, 2006 5:52 AM by Angus
Hi Scott - one more thing please. How do I "point" the existing providers to use my own connection-string name in place of the default LocalSqlServer one. Thanks so much. Angus

# Health Monitor or Not to Health Monitor?

Friday, September 08, 2006 11:07 AM by Wizards Space

That is the question, in shared hosting [ aspnet ]. Here is my problem, we run many web servers with

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Saturday, September 09, 2006 6:05 PM by IanC
Hi Scott, when I try to use the ASP.NET SQL Server Setup Wizard, I get the following error when I try to connect to the SQL Server and get a list of the databases: "Failed to query a list of database names from the SQL Server. Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." I get the same "Timeout expired" message when I try to add a connection in the Server Explorer of Visual Studio 2005, and my app fails when trying to connect to the Server. Enterprise Manager works fine on my computer and can access the SQL Server on the remote server, and the Server Explorer in Visual Studio .net 2003 works fine - I can see all databases, tables etc, it's just that I CANNOT get access to the server using Visual Studio 2005. What's going wrong? I am getting SOOOO frustrated with this problem, this is now my second day trying to fix it!! Please help?!

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Monday, September 11, 2006 5:03 AM by Lee Campbell
Thanks for the tip Scott. But why was this post required. If the process made any sence at all and didnt require knowledge that 1. this is intended for SQLExpress, 2. the connection string must be "LocalSqlServer", 3. you have to run a script or comand line to get it all to work; you probably wouldt have had to write the tips in the first place. I was really expecting all of that to happen when i hit the button in VS2k5. (ie, check my conn Strings, ask which one to use or create a Db if I didnt have one, and put all the setting in to the web.config.) Im not trying to be negative, but this is a surprisingly bad implementation compared to the awesome work your team has done on so much other stuff. My 2c. Lee

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, September 12, 2006 10:47 AM by ScottGu

Hi Ian,

It sounds like you have a security configuration mis-set potentially.  Can you check to see how you are connecting to the remote machine in the VS 2005 Server Explorer?  Does it have the exact same connection string as how you are using it in VS 2003?

Thanks,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, September 12, 2006 10:51 AM by ScottGu

Hi Angus,

Yep -- you can change the connection string name to whatever you want.  Simply add a new provider declaration under <membership>, <roles>, etc and point it at your new connection string name.

Hope this helps,

Scott

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Tuesday, September 12, 2006 11:45 AM by IanC
Scott, Thanks for your reply. I am not actually generating a connection string when using the Server Explorer in VS2005, I am just right-clicking "Data connections" and selecting "Add connection". I then select the server name from the drop down list, and no matter whether I select "Windows Authentication" or "SQL Server authentication" (and enter the correct details) I cannot list any of the databases on the SQL Server. It seems that there is some kind of configuration issue with VS2005 preventing connection to a remote SQL Server, whereas in VS.net 2003 on the same computer and accessing the same SQL Server, it's fine. One more point, I can't seem to connect to the local SQL Server 2005 with VC2005 either! I'm sure it is something ridiculously simple, but what?!!! Thanks in advance for your help. Ian.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Wednesday, September 13, 2006 3:26 AM by IanC
Scott, I have now FINALLY (now after FOUR days of trying!!) managed to connect to my SQL Server 2000 database with VS2005 Server Explorer by increasing the connection timeout value to 50 seconds. The connection connects in about 45 seconds. My application also works by extending the connection timeout. However, as I am sure you can appreciate, this causes a totally unnaceptable delay in the application while the connection is first opened. How can I reduce/remove this delay? I don't have ANY delays when using VS.net 2003! Why is it taking so long to connect? Will it be a conflict with the local version of SQL Server 2005? Is it best to uninstall SQL Server 2005 on the local computer?

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, September 14, 2006 4:18 AM by IanC
Scott, I'm sorry to keep sending messages, and I'm sure that this is not the right place to be asking for help, but I can't find any help anywhere else!! This is getting ridiculous! Last night, without making ANY CHANGES WHATSOEVER (I was previously working on another computer, and not going anywhere near SQL Server either), I could connect to SQL Server 2000 with Visual Studio 2005's Server Explorer, and my application worked with no delays whatsoever to open the connection to the server. I then worked on my application for a few hours and went to bed and it was all working, went to have another look this morning and I cannot connect to the SQL Server again, no matter WHAT I set the Connection Timeout to!! What's going on?! Do you have ANY ideas?! Thanks in advance, Ian.

# re: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

Thursday, September 14, 2006 1:35 PM