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.
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.