Link to home
Start Free TrialLog in
Avatar of stormreader
stormreader

asked on

Cannot open user default database. Login failed.

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.
Avatar of stormreader
stormreader

ASKER

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?
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'.
ASP.NET account was granted, but how can I grant a specific database for a specific user?
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?
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.
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.
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.
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.
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
Make sure that your database files are not read-only.
I did not make them read-only, so they must be read-only, no?
If you have used a CDROM to copy them from home then they are read-only. Check them.
No, they are not.
ASKER CERTIFIED SOLUTION
Avatar of profya
profya
Flag of Sudan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 :)