Monday, February 13, 2012

Asp.Net not finding the SQLServer for setting up Security problem

I have just reciently installed and started upgrading the last beta code to this beta and am having a problem conecting to my sqlinstance with the WebSite Configuration Tool.

The error indicates it is looking for a file in the app_data directory. (empty), but everthing else points to SQLServer (express) as being the issue.

I have run aspnet_regsql.exe (both on my default instance of sql (a sql2kas) and the beta2 instance that shipped with VS.

Both created datasases and eveyting looked good inside the db's.

However when I click the "Securtiy tab" I get a message "Unable to connect to SQL Server Database."

When I go to The Provider Tab, there is nothing to configure, just a test Hlink that generates the following when clicked.

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 .......

I have run SQL Trace (profiler) against both instances of SQL when aps is trying to connect, but neither show anything.

I keep feeling like I must have missed something.. Anyu clues are welcome.

Rob

The issue was the Machine.Config file and the fact that when I named my new instance of SQL2005, I installed it using a NonDefault name.

This I fixed by editing the Machine.Config file and changing the Connection String for the Database Access. (Can't remember just which one, but if you do a search for SQLExpress in teh machine.config you will find it.)

HTH

Rob
Smile|||Here is another approach in using a full blown SQL Server as the repository of your credentials for ASP.NET 2.0 if you do not want to use the default SQL Express.

1) Create a database in SQL Server (2000 or 2005) and make sure that you give the ASPNET account permissions to this database.
2) Run the aspnet_regsql.exe file in your System%Root\Microsoft.NET\Framework\v2.0.xyz directory. This will open an ASP.NET SQL Server Setup Wizard which will create the objects necessary for ASP.NET security.
3) Point to the database you just created.
4) In your web.config file, locate the <connectionStrings> element and add the following:

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;initial catalog=<your database name>;integrated security=true" providerName="System.Data.SqlClient">

This overrides the default SQL Express and points to the new database you just created - be it in the same machine or a different machine. You can also change the configuration in the machine.config file although this will affect every web application sitting on top of your machine.|||WOW! it did solve my problem. thanks so much|||

Worked !

Thanks a lot.

(I can now start growing my hair back )

Bill

|||

I have the same problem :S

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

i still get error

Error 4 XML document cannot contain multiple root level elements.

:S:S


|||

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

I think your error might be pointing to the Add tag as it is missing the Close Tag. However you seem to have an XML issue, not the issue that started the thread..

Rob

E.G. (highlighted in red)

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;integrated security=true " providerName="System.Data.SqlClient" />

|||Is it mandatory to have SQL Server for accessing the security features like creating users and roles in ASP.Net Configuration tool? If not please tell me the way to avoid the same problem...|||

Hi bass_player,

I think I was a bit late in getting this error, but when I got it in 2007 your post of 2005 saved my day.

Thanks a lot

RaghavS

|||hi
the first three steps done greatly
the fourth is not
i did not find any<connectionStrings> in my web.config

i'm just a beginer
thank u
|||

Place the <connectionstrings>...</connectionstrings> section right before the <system.web> seciton

No comments:

Post a Comment