1

I'm in SQLSERVER (2008 R2 EXPRESS) administrators list. I'm in administrator role on my machine. And I can manually connect to SQLSERVER (via Management Tools) using ServerName (in my case it's S-PROG-T\SQLEXPRESS). During installation I decided to use only Windows Authentication mode. I can't connect to SS.

Error message is: Login failed for user S-PROG-T\admin. Cannot open database 'ProjectDB' requested by the login.

I'm using the following configuration for NHibernate:

<session-factory>
    <property name="connection.provider">
        NHibernate.Connection.DriverConnectionProvider
    </property>
    <property name="dialect">
        NHibernate.Dialect.MsSql2008Dialect
    </property>
    <property name="connection.driver_class">
        NHibernate.Driver.Sql2008ClientDriver
    </property>
    <property name="connection.connection_string">
        Data Source=S-PROG-T\SQLEXPRESS;Initial Catalog=ProjectDB;Integrated Security=SSPI
    </property>
    <property name="show_sql">
        true
    </property>
    <mapping resource="Project.Domain.Model.Entities.Mappings.Vehicle.hbm.xml" assembly="Project.Domain" />
 </session-factory>

And I've tried to connect using .\SQLEXPRESS data source. Inbound rules don't restrict SSMS.

What's wrong? Thanks!

EDIT: Unit tests

Everything (nhibernate configuration, and schema export trial) starts inside my unit test (I don't know if this matters).

[TestFixture]
public class VehicleFixture
{
    [Test]
    public void TestSchemaExport()
    {
        new SchemaExport(new Configuration().Configure()).Execute(false, true, false);
    }
}

EDIT: Log information

I discovered the next information inside a log (path: %ProgramFiles%\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Log\):

Error: 18456; State: 38.

Login failed for user ‘S-PROG-T\Admin’.

Reason: Failed to open the explicitly specified database.

According to the article: http://sql-articles.com/articles/troubleshooting/troubleshooting-login-failed-error-18456/ database doesn’t exist or login doesn’t have access to the database.

I'm totally confused. Should I have created the database (manually) before I tried to export schema (sorry if the question is silly)?

EDIT: Using Mixed Authentication mode

I've set Mixed mode Authentication and created new login with serveradmin & sysadmin roles. But still the error message is the same, except for user name. Again I can manually do the same thing (connect and create db) with the login and its password.

6
  • What programming language are you using?
    – Kinexus
    Dec 16, 2011 at 13:42
  • Why are there two spaces in "Integrated Security"? Dec 16, 2011 at 13:48
  • @WernerHenze that's not the culprit. The typo exists only here.
    – lexeme
    Dec 16, 2011 at 14:25
  • Does it work when you omit the Initial Catalog? (-> Issue when connecting to the server or issue when opening the database?) Are you using Win7? If yes, are you running the Management Tools and your own program "as administrator"? Dec 16, 2011 at 16:09
  • Can you connect with Windows Authentication mode with the Manager tool? You say that you are admin on your machine, but what about where you install the database? Dec 19, 2011 at 14:38

3 Answers 3

1

Ok. I misunderstood the whole process. Everything's ok with Authentication and rather with connection strings. I just thought that schema export stands for database automated-creation and then schema export. So I created a DB and successfully exported a schema.

0

Can you connect with NHibernate if you change database to 'master'?

Is ProjectDB database user S-PROG-T\admin mapped to server login that you use to connect using management tools?

Can you connect to database using user/password combination in property name="connection.connection_string" instead of integrated security = SSPI?

EDIT You write that you created new login. But still - login is something used for SERVER authentication. You must have database user in ProjectDB mapped to server login to access the database.

Look at this thread: TSQL to Map User to Database

or read here: http://www.nerdymusings.com/LPMArticle.asp?ID=41

-1

The website will not be using the same identity, therefore will not be an administrator. You can either define a specific identity and set your ApplicationPool (or your own admin account) to use this. Alternatively, use a login/password rather than integrated security.

1
  • 1
    Looks like he cannot even get in as his specific identity Dec 16, 2011 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.