Tuesday, March 27, 2012

login failed

hi!
i have just started learning ASP.NET and i am trying to create my own forum by following tutorials. I have installed: .NET Framework, MSDE and Web Matrix.
I have configured the db with these commands: sp_grantlogin and sp_addsrvrolemember
But i think that i cant login/write information to my database. All i get is this error message:

Server Error in '/' Application.
------------------
-------

Cannot open database requested in login 'dbDiskForum'. Login fails. Login failed for user 'SRVU\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database requested in login 'dbDiskForum'. Login fails. Login failed for user 'SRVU\ASPNET'.

Source Error:

Line 24: sqlCommand.Parameters.Add("@dotnet.itags.org.forumBeskrivning", System.Data.SqlDbType.VarChar).Value = forumBeskrivning
Line 25:
Line 26: sqlConnection.Open
Line 27: Try
Line 28: sqlCommand.ExecuteNonQuery

Source File: c:\inetpub\wwwroot\diskforum\dbAdmin.vb Line: 26

Stack Trace:

[SqlException: Cannot open database requested in login 'dbDiskForum'. Login fails.
Login failed for user 'SRVU\ASPNET'.]
System.Data.SqlClient.SqlConnection.Open() +761
dbAdmin.addForum(Object sender, EventArgs e) in c:\inetpub\wwwroot\diskforum\dbAdmin.vb:26
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEven
tHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263

------------------
-------
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0

What should i do? Excuse my bad english... txyou need to add the user 'SRVU\ASPNET' to the users in the database. when you expand the database you are working on in Enterprise Manager you will see a Users tab. here you can add/modify user's permissions.
if you have tried sp_grantlogin and sp_addsrvrolemember

try:

exec sp_grantdbaccess
@.loginame = 'SRVU\ASPNET'
go

or:

exec sp_addrolemember N'db_datareader', N'SRVU\ASPNET'
exec sp_addrolemember N'db_datawriter', N'SRVU\ASPNET'

hope this helps

Tom
Hi,
Just to add to the response from ndinakar, if you are using Windows Server 2003, change ASPNET to NETWORK SERVICE. Also, if you are using MSDE, you likely don't have SQL Server tools like Enterprise Manager. You can accomplish the same thing using the command line tool OSQL. If you'd like an easier way to manage MSDE, go to the Microsoft site and find the MSDE page. There, they have some links to low cost and shareware managers from third parties that are easier to use than command line tools. Good luck.

0 comments:

Post a Comment