Been looking through the forums for a solution to this problem.
I already tried granting access through statements such as:
exec sp_grantloginaccess N1'machineName\ASPNET'
But they don't seem to work.. i vaguely remember seeing somewhere a DOS command line statement that grants access to the ASPNET_WP and that fixed my problem before on another computer.. but this is a new computer and i forgot to write down the command.
Can anyone help explain and propose a solution to my problem. Many thanxs.
You need to grant login permissions to the ASPNET account as well as database permissions. Do you have Enterprise Manager? This would help you to set permissions using a GUI tool. Assuming you do not, then you could use the osql commandline utility. I am
also further assuming this is a local instance of SQL Server.
Using osql, from the command prompt, this
will connect you to your instance of SQL Server and put you into an interactive mode with osql:
osql -E -S (local)
Now you can enter the commands in the interactive
mode:
I went with tmorton's instructions because it looked easier and more straightforward. I enabled me to get my app running after a few minor adjustments. I described what I did below but don't fully understand why it worked. Could you please help clarify?
I was able to grantlogin to 'machineName\ASPNET', however, got an error stating that permissions already existed for 'machineName\ASPNET' when I tried to grantdbaccess. I do have EnterpriseManager and went into the Users of the database I needed to use. I deleted
the 'machineName\ASPNET' from that list. Then ran the sp_grantdbaccess 'machineName\ASPNET' again. This time succeeding. Thus my application has permissions to run. But when I went back ino the database/users, I didn't see 'machineName\ASPNET' in the User
list. Why is that?
Where can I look to see the results of executing the sp_grantlogin & sp_grantdbaccess? Shouldn't there be a list for that somewhere?
And just to make sure that I understand what is happening. The sp_grantlogin simply gives the user 'machineName\ASPNET' permission to login into the SQLServer (1st level). Then sp_grantdbacess gives the user 'machineName\ASPNET' permission to access the specified
database (from the use yourDatabase)
After referring someone else to this post I realized that I never answered your questions. I am sorry!
MEight
Thanxs '%orton'
I was able to grantlogin to 'machineName\ASPNET', however, got an error stating that permissions already existed for 'machineName\ASPNET' when I tried to grantdbaccess.
Then you really didn't need to do anything further with *that* command.
MEight
I do have EnterpriseManager<snip>
But when I went back ino the database/users, I didn't see 'machineName\ASPNET' in the User list. Why is that?
Enterprise Manager is not good about refreshing data. Either close Enterprise Manager completely and reopen it, or start at your server right-clicking and choosing Refresh on each node all of the way down until you get to the node for the data you are concerned
with.
MEight
Where can I look to see the results of executing the sp_grantlogin & sp_grantdbaccess? Shouldn't there be a list for that somewhere?
You can see this in Enterprise Manager (after forcing the data to refresh), or you can execute the
sp_helplogins system stored procedure from Query Analyzer (or the osql commandline utility):
EXEC sp_helplogins
MEight
And just to make sure that I understand what is happening. The sp_grantlogin simply gives the user 'machineName\ASPNET' permission to login into the SQLServer (1st level). Then sp_grantdbacess gives the user 'machineName\ASPNET' permission to access the specified
database (from the use yourDatabase)
C:\Users\User>osql -E -S
[SQL Native Client]VIA Provider: The specified module could not be found.
[SQL Native Client]Login timeout expired
[SQL Native Client]An error has occurred while establishing a connection to
the server. When connecting to SQL Server 2005, this failure may be caused by
the fact that under the default settings SQL Server does not allow remote
connections.
I am getting the same error message when i click a tickbox (ispostback function - which changes some controls property value of visiable from false to true) on my contact form. It never used to do it, its just started suddenly, so i dont see why it would
happen? I'm not sure what to do with the code you provided above :S - incidently, its only when i click that button, the form itself will send fine if not clicked.
I'm using VS08 / SQL 2005
Regards,
Daniel
I haven't failed. I've just found 10,000 ways that don't work.
You need to grant login permissions to the ASPNET account as well as database permissions. Do you have Enterprise Manager? This would help you to set permissions using a GUI tool. Assuming you do not, then you could use the osql commandline utility. I am
also further assuming this is a local instance of SQL Server.
Using osql, from the command prompt, this
will connect you to your instance of SQL Server and put you into an interactive mode with osql:
osql -E -S (local)
Now you can enter the commands in the
interactive mode:
1>EXEC sp_grantlogin 'machineName\ASPNET'
2>GO
1>USE yourDatabase
2>GO
1>EXEC sp_grantdbaccess 'machineName\ASPNET'
2>GO
1>EXIT
I also tried this as the user above me has to which I got the same error message. Is there any other way this can be rectified?
Regards,
Daniel
I haven't failed. I've just found 10,000 ways that don't work.
Ok for me, I just remade my connectionstring(s) , after deleting them in the webconfig, then using a drag and drog SqlDataSource control to create the new connectionstring and insert the code in the webconfig automatically.
I haven't failed. I've just found 10,000 ways that don't work.
MEight
Member
89 Points
107 Posts
Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machineName...
Jul 27, 2005 05:44 PM|LINK
Been looking through the forums for a solution to this problem.
I already tried granting access through statements such as:
exec sp_grantloginaccess N1'machineName\ASPNET'
But they don't seem to work.. i vaguely remember seeing somewhere a DOS command line statement that grants access to the ASPNET_WP and that fixed my problem before on another computer.. but this is a new computer and i forgot to write down the command.
Can anyone help explain and propose a solution to my problem. Many thanxs.
DarrellNorto...
All-Star
86665 Points
9634 Posts
Moderator
MVP
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Jul 27, 2005 06:34 PM|LINK
osql -E -S InstanceName -d database -Q "sp_grantdbaccess 'computer\ASPNET'"
osql -E -S InstanceName -d database -Q "sp_addrolemember 'db_owner', 'computer\ASPNET'"InstanceName -C -Q "sp_grantlogin 'computer\ASPNET'"
InstanceName is optional if you only installed the default instance.
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
tmorton
All-Star
56355 Points
9689 Posts
ASPInsiders
Moderator
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Jul 27, 2005 06:35 PM|LINK
Using osql, from the command prompt, this will connect you to your instance of SQL Server and put you into an interactive mode with osql:
Now you can enter the commands in the interactive mode:
Edit: sorry, didn't see Darrell's post :-)
ASP.NET/IIS.NET Website Manager, Neudesic
DarrellNorto...
All-Star
86665 Points
9634 Posts
Moderator
MVP
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Jul 28, 2005 08:26 PM|LINK
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
MEight
Member
89 Points
107 Posts
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Jul 29, 2005 02:40 PM|LINK
I went with tmorton's instructions because it looked easier and more straightforward. I enabled me to get my app running after a few minor adjustments. I described what I did below but don't fully understand why it worked. Could you please help clarify?
I was able to grantlogin to 'machineName\ASPNET', however, got an error stating that permissions already existed for 'machineName\ASPNET' when I tried to grantdbaccess. I do have EnterpriseManager and went into the Users of the database I needed to use. I deleted the 'machineName\ASPNET' from that list. Then ran the sp_grantdbaccess 'machineName\ASPNET' again. This time succeeding. Thus my application has permissions to run. But when I went back ino the database/users, I didn't see 'machineName\ASPNET' in the User list. Why is that?
Where can I look to see the results of executing the sp_grantlogin & sp_grantdbaccess? Shouldn't there be a list for that somewhere?
And just to make sure that I understand what is happening. The sp_grantlogin simply gives the user 'machineName\ASPNET' permission to login into the SQLServer (1st level). Then sp_grantdbacess gives the user 'machineName\ASPNET' permission to access the specified database (from the use yourDatabase)
Thanxs again!!!
tmorton
All-Star
56355 Points
9689 Posts
ASPInsiders
Moderator
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Sep 11, 2005 04:32 PM|LINK
Then you really didn't need to do anything further with *that* command.
Enterprise Manager is not good about refreshing data. Either close Enterprise Manager completely and reopen it, or start at your server right-clicking and choosing Refresh on each node all of the way down until you get to the node for the data you are concerned with.
You can see this in Enterprise Manager (after forcing the data to refresh), or you can execute the sp_helplogins system stored procedure from Query Analyzer (or the osql commandline utility):
Yes, you've got it! You can read up on what MSDN has to say about sp_grantlogin and sp_grantdbaccess for more information.
If you haven't done so already, you should install SQL Server 2000 Books Online. This is a great free SQL Server reference.
ASP.NET/IIS.NET Website Manager, Neudesic
oneBottonSal...
Member
2 Points
1 Post
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Aug 02, 2007 05:01 AM|LINK
i can not do anything with sql. This is what i got :
-------------------------------------------------------------------------------------------
C:\Users\User>osql -E -S
[SQL Native Client]VIA Provider: The specified module could not be found.
[SQL Native Client]Login timeout expired
[SQL Native Client]An error has occurred while establishing a connection to
the server. When connecting to SQL Server 2005, this failure may be caused by
the fact that under the default settings SQL Server does not allow remote
connections.
------------------------------------------------------------------------------------------
also, i cant create database directly from SQL Server Management Studio Express!
the error is The permission denied in database 'master'. What should i do?
dt86uk
Member
107 Points
132 Posts
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Jun 02, 2010 02:21 AM|LINK
I am getting the same error message when i click a tickbox (ispostback function - which changes some controls property value of visiable from false to true) on my contact form. It never used to do it, its just started suddenly, so i dont see why it would happen? I'm not sure what to do with the code you provided above :S - incidently, its only when i click that button, the form itself will send fine if not clicked.
I'm using VS08 / SQL 2005
Regards,
Daniel
dt86uk
Member
107 Points
132 Posts
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Jun 07, 2010 12:13 PM|LINK
I also tried this as the user above me has to which I got the same error message. Is there any other way this can be rectified?
Regards,
Daniel
dt86uk
Member
107 Points
132 Posts
Re: Cannot open database requested in login 'dbName'. Login fails. Login failed for user 'machine...
Jun 07, 2010 12:37 PM|LINK
Ok for me, I just remade my connectionstring(s) , after deleting them in the webconfig, then using a drag and drog SqlDataSource control to create the new connectionstring and insert the code in the webconfig automatically.