Tuesday, March 27, 2012

login failed

Environment: VS 2005 with .NET 2.0, SQL Server 2005 Database

My domain login in SQL 2005 security/logins has db_owner rights on the Catalog I'm referencing:

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "dbname" requested by the login. The login failed.
Login failed for user 'domain\myaccount'.

Source Error:

Line 25: try
Line 26: {
Line 27: Conn.Open();
Line 28: SqlCommand GetURLsCommand = new SqlCommand("GetURLs", Conn);
Line 29: GetURLsCommand.CommandType = CommandType.StoredProcedure;

My web.config connection section is:

<connectionStrings>

<addname="MyConn"

connectionString="Data Source=.;

Initial Catalog=JDVTestData;

Integrated Security=True;"/>

</connectionStrings>

I have integrated Windowsm Authentification and Anonamous checked in my IIS settings

Here's how I'm passing the connection information to my class from my code-behind which uses it to fill my dataset:

GetListURLs geturls =newGetListURLs(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString);

Why do I still get this error on Conn.Open(); ??

Hi again, I think the actual problem is in SQL Server. Try open Sql Enterprise Manager, choose local server/Security/Logins, right-click -> New Login and fill the first textbox with"domain/myaccount", and under "Database Access" tab, check your database

hope that helps


Ups, just ignore my last post, I see you already have your domain/account to have access to your db in other post, sorry

Hi, you can double confirm that the account has been mapping to the owner of the requested database as following:

1. Connect to the SQL Server using an account which is member of sysadmin role (for example 'sa', or local Windows Authentication)

2. New a query, run the script below:

useJDVTestData

go

exec sp_revokedbaccess 'domain\myaccount'

exec sp_grantdbaccess 'domain\myaccount'

exec sp_addrolemember db_owner,'domain\myaccount'


I changed the connection string to use the correct SQL instance. I didn't have it named as local in SQL 2005 Management Studio, I had it actually as pcname\LOCAL

that fixed it!


meaning in my web.config...

0 comments:

Post a Comment