Solved

Cannot open user default database. Login failed.

Posted on 2006-12-01
15
1,794 Views
Last Modified: 2012-08-13
Cannot open user default database. Login failed.
Login failed for user 'GGEM-1\ASPNET'.

The problem is this.

I am trying to develop a webpart project with Asp.Net 2.0
It had worked at my home, but when I come to office, I met with this error.
I have configured my 'Asp.Net Web Configuration Settings' on Microsoft Visual Studio. It works properly.
I am using 'Windows authentication' on my sql server.
On IIS > default web site > properties > folder security > anonymous communication
                anonymous communication box is clear(false), integrated windows authenticion is set (true).
Aspnet_regsql worked normal.

Despite of these I am still having this problem.
How can I solve it? , please help.
0
Comment
Question by:stormreader
  • 8
  • 6
15 Comments
 

Author Comment

by:stormreader
Comment Utility
I have added a user like 'GGEM-1\ASPNET' in Management Studio and this error was solved.
But ...
A new error appeared, I can't login with any of my users.
I can create users with 'ASP.NET Web Site Configuration', but when I want to login, it says 'Your login attempt was not successful. Please try again.' on my 'validation summary control'.
When I try to create a user with 'CreateUserWizard' which is at toolbox > login , it says :
                      ' Failed to update database "C:\INETPUB\WWWROOT\WEBPART\APP_DATA\ASPNETDB.MDF" because the database is read-only. '

now how can I solve this?
0
 
LVL 14

Expert Comment

by:profya
Comment Utility
Your database files (both MDF and LDF files) are located on a read-only directory. 'GGEM-1\ASPNET' account which is used by the ASP.NET to access server's resources does not have appropriate access permissions on 'C:\INETPUB\WWWROOT\WEBPART\APP_DATA\ASP' directory. Try granting 'GGEM-1\ASPNET' change permissions on 'C:\INETPUB\WWWROOT\WEBPART\APP_DATA\ASP'.
0
 

Author Comment

by:stormreader
Comment Utility
ASP.NET account was granted, but how can I grant a specific database for a specific user?
0
 

Author Comment

by:stormreader
Comment Utility
Yes, the user account (ASP.NET) has write access.

What I can do now is that I can run my application in a folder named 'deneme', but when I create a new folder in wwwroot by iis, I cannot run it again in the new folder named 'tbd', I also give the write permission for 'ASP.NET' user but I meet the same erroor :

Failed to update database "C:\INETPUB\WWWROOT\TBD\APP_DATA\ASPNETDB.MDF" because the database is read-only.

How can I solve this?
0
 
LVL 14

Expert Comment

by:profya
Comment Utility
I don't know but I think it is related to the settings of your application. First make sure that your application is using the database placed in the new folder you have created and granted the WRITE permission. You can examine the connection string in the application config file. If you treat the database as a client/server rather than file-based database you may be able to overcome all the problems you encounter. client/server database access does not require to point to the database file name in the connection string, rather you just use the server's name along with the database name and user/password combination to access the database, whereever the database is located on the server.
0
 

Author Comment

by:stormreader
Comment Utility
I do not use a connection string in my web.config file, it worked in my home, and I think it must work at office.
I do not define a .mdb file for the application, it is related about ASP.NET, it uses its own database and it must not need a connection string for it, I think.
I did not meet any connection string definition for webpart applications, I think.

But thanks for your advice, I will try it.
0
 
LVL 14

Expert Comment

by:profya
Comment Utility
There should be a connection string somewhere for sure. ASP.NET works with different types of database, yes, the default is SQL Server Express. To ensure look at:
<connectionStrings>
        <add name="ConnectionString" connectionString="Data Source=.\SQLXP;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
in you web config file.

As I said earler, the whole problem is related to the permissions you set on the database files and the folder containing them. If the ASP.NET has the proper permission now then the problem is with database files, they are read-only as I guess, may be because you used a CD to copy them from home and when you copy from a CD destination files are always marked as read-only.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:stormreader
Comment Utility
I wrote <connectionstring> .... into my web.config file, but it didn't work.

I can run it in a folder - and only - now in office, I copied the files from it, and when I pasted it in an other folder which has right permissions, it does not run in the new folder.

Now what might have been done ?

I am realy very confused.
0
 
LVL 5

Expert Comment

by:MrNetic
Comment Utility
stormreader,

Because you have done lots of things and you dont quite remember what you have done.

Run SQL Server Profiler, to watch how the software is connecting to the DB.

Best Regards, Paulo Condeça
0
 
LVL 14

Expert Comment

by:profya
Comment Utility
Make sure that your database files are not read-only.
0
 

Author Comment

by:stormreader
Comment Utility
I did not make them read-only, so they must be read-only, no?
0
 
LVL 14

Expert Comment

by:profya
Comment Utility
If you have used a CDROM to copy them from home then they are read-only. Check them.
0
 

Author Comment

by:stormreader
Comment Utility
No, they are not.
0
 
LVL 14

Accepted Solution

by:
profya earned 500 total points
Comment Utility
Ok. There is tow ways you can follow to resolve the problem. One: Is to recheck the permissions for the ASPNET account, the second is to attach your database to the SQL Server and change the connection string in your web config file to use client/server approach in accessing the database from within your application. The second way is the easiest, but it needs knowledge on how you can access SQL Server's management studio and on how you can attach your database to SQL Server. The connection string then is easy to build, "Data Source=<your database server's name>; Initial Catalog=<your database name>; Integrated Security=SSPI" if you are using windows authentication or "Data Source=<your database server's name>; Initial Catalog=<your database name>; User ID=<user name>; Password=<user password>" if you are using SQL Server authentication.
The first way needs to recheck both folder and file permissions. It is a matter of configuration, nothing more as I think.
0
 

Author Comment

by:stormreader
Comment Utility
What I did is :
I adjusted connectionstring to AttachDBFilename=c:\inetpub\wwwroot\tbd\App_Data\tbd.mdf
I added a user called ASPNET in sql server management, and then  I added it into my tbd.mdf database users.
I gave ASPNET permission to read-write for tbd.mdf in management studio and App_Data folder and also tbd.mdf and tbd.ldf .

It worked for a long time, but today again an error has appeared like
             Cannot open user default database. Login failed.
             Login failed for user 'SYF\ASPNET'.

When I run it like localhost/tbd/z.aspx, it appears.
But when I run it in VWD, it runs as "http://localhost:1639/tbd/z.aspx" , and whola it woks.


But why does it not work in local?
Thanks for your incoming help :)

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now