Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cannot open user default database. Login failed.

Posted on 2006-12-01
15
Medium Priority
?
1,803 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
15 Comments
 

Author Comment

by:stormreader
ID: 18053636
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
ID: 18055753
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
ID: 18059082
ASP.NET account was granted, but how can I grant a specific database for a specific user?
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:stormreader
ID: 18059798
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
ID: 18063072
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
ID: 18063094
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
ID: 18063281
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
 

Author Comment

by:stormreader
ID: 18063782
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
ID: 18068752
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
ID: 18074828
Make sure that your database files are not read-only.
0
 

Author Comment

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

Expert Comment

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

Author Comment

by:stormreader
ID: 18084112
No, they are not.
0
 
LVL 14

Accepted Solution

by:
profya earned 2000 total points
ID: 18110202
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
ID: 18152150
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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