Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Database Access Issue

Author  Topic 

sql_newbie121
Yak Posting Veteran

52 Posts

Posted - 2010-01-05 : 10:08:09
Situation:
There is a production database named Test and I have created a new database on the test database named Test. Also created user name with same privileges that has in production database. But I get this error from the application side. There is nothing difference in database setting and authentication. Production database has sql login and test database also has SQL Login.
===============================================================
Preparing email: Exception: System.Data.Odbc.OdbcException: ERROR [08004] [Microsoft][ODBC SQL Server Driver][SQL Server]The server principal "test" is not able to access the database "Test" under the current security context. at Test.DBClassEmail.saveEmail(String msgSubject, String msgto, String msgCC, String msgBcc, String msgFrom, String msgBody) at Test.List_Test.Save_Click(Object sender, EventArgs e)

===============================================================
Please advice me on this issue.

Thanks.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-05 : 11:32:12
is login (or server principal) test granted access to database test?

CREATE USER [test] FOR LOGIN [test] WITH DEFAULT_SCHEMA=[dbo];
GO
EXEC sp_addrolemember @rolename = 'db_datareader', @membername = 'test';
GO
Go to Top of Page

sql_newbie121
Yak Posting Veteran

52 Posts

Posted - 2010-01-05 : 16:51:07
I did that and it is still not working. it is really frustrating here.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-01-06 : 01:37:56
let's see the connection string
Go to Top of Page

sql_newbie121
Yak Posting Veteran

52 Posts

Posted - 2010-01-06 : 10:03:05
Well, i found the problem. It is so stupid that while i migrated the stored procedures, in the Insert Command they have used 3 parts name databasename.dbo.object name and that should not be the case and each time when it is tried to connect from the application, it is trying to point to the old database. I found out that and removed the old database name from the stored procedures, it worked like a charm. Thanks russ for your help.
Go to Top of Page
   

- Advertisement -