asp.net 2.0 login control
- From: Freddie <sure@xxxxxxxx>
- Date: Tue, 01 Aug 2006 20:34:10 +0300
this is surely the wrong group, but you guys have been so helpful in the past ...
i want to use the new forms authentication in asp.net 2.0 with sql server 2005 dev edition
so i created a login with administrator priviles in the DBMS and gave all filesystem permissions to the aspnet account(this is Win 2k Pro, also tried another account with impersonation)
this is my mashine.config connection string:
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=false;" providerName="System.Data.SqlClient" />
</connectionStrings>
and this is the exception i get:
[SqlException (0x80131904): An attempt to attach an auto-named database for file c:\inetpub\wwwroot\WebSite\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.]
so far i`ve tried these fixes from the web, but no luck :(
"
These problems left me stranded for days, then today, on another machine, I hit a different set of problems I kept getting the following "Failed to generate user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed." and if I set "User Instance" to false the following "An attempt to attach an auto-named database for file C:\[app_path]\ASPNetDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
...
If you don't want to follow the link, the short answer is that SQLExpress creates a directory per user in "c:\Documents and Settings\[user]\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS" that it uses to store information. Deleting this directory has fixed both of my problems.
Avoid the new feature that allows hot swapping and XCOPY deployment of SQL databases on your development machine. (Basically this is a new option in the connection string that allows you to point out where the ..mdf file resides eliminating the need to create database in some SQL instance.) This feature may be useful in production site, but it has some side effects.
Beware that the windows account of the user that first creates the connection in this databaseless manner, becomes exclusive user for this file and no other windows account will be able to create a connection to this file. The error is quite useless in this case:
“An attempt to attach an auto-named database for file C:\acme.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.”
Also keep in mind that in one occasion I had to give write access to NETWORK SERVICE account to the folder above the one that was holding my ..mdf file. I have not research it what is the case however.
You have to specify Initial Catalog=xxx , though I'm not quite sure what this is supposed to be.
We do know what the problem is, in fact its in our FAQ section. Most of the time xxx should be same as the name of your db file. Ex abc.mdf , then you need to use initial catalog=abc
In these circumstances Google is your friend. I found this post on a Microsoft forum. If you don't want to follow the link, the short answer is that SQLExpress creates a directory per user in "c:\Documents and Settings\[user]\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS" that it uses to store information. Deleting this directory has fixed both of my problems.
1. Open SQL Server Management Studio and attach the .mdf file manually to the SQL Server. (Select the 'Databases' node, Right click and select 'Attach')
Now change your web.config and change the connection string to point to the pre attached database instead of auto attach.
2. SQLExpress creates a directory per user in "c:\Documents and Settings\[user name]\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS" to store some information. Delete this directory and try again.
3. The windows account "ASPNET" must have write permission on the folder. If it is a Windows 2003 machine, provide write access to the account "NETWORK SERVICE" on the folder, instead of account ASPNET.
4. You may want to disable the "User Instance=true" and try.
5. Are you using beta versions of VWD, Visual Studio 2005 or SQL Server 2005 Express? Uninstall them and install the released versions.
6. User Instance=True will work only if your SQL Server 2005 Express is using Windows Authentication mode. It will fail if you are using mixed mode. (Select the computer name in the SQL Serve r Management Studio, right click and select 'Properties'. Select the node 'Security' to view/change the authentication mode)
7. Make sure your connection string is correct. It must be something like below:
"Data Source=.\SQLExpress;Persist Security Info=True;Integrated Security=SSPI;Initial Catalog=YourUserId_DatabaseName"
When you use Integrated Secuiryt=SSPI in the connection string, make sure you are using <identity impersonate="true" /> in the <system.web> section of the web.config and also make sure to specify a valid windows account for the "Anonymous User" access section in IIS.
"
i`m already late with this app and having a file database is a must have(and no Jet is not an option :)
so any advice, link or idea are more than welcome
thanks
(and plz excuse my bad english)
.
- Prev by Date: Re: Auto Increment Version in VB 2005
- Next by Date: VB.NET Datagrid Sorting of Numbers
- Previous by thread: Re: Date Sort
- Next by thread: VB.NET Datagrid Sorting of Numbers
- Index(es):
Relevant Pages
|