Click here to Skip to main content
15,924,367 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am new to nhibernate. I read an article and according to it I tried to create db with domain object.

My config file :
XML
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=FADIK-TOSH\SQLEXPRESS;Database=DatabaseNHB;Trusted_Connection=True;</property>
    <!--<property name="connection.connection_string">Data Source=DatabaseNHB.mdf</property>-->
    <property name="show_sql">true</property>
    <!-- we want to see the SQL NHibernate generates and sends to the database (highly recommended for debugging purposes during development) -->
  </session-factory>
</hibernate-configuration>



My sql server is default so there is no sql server authentication. I login with windows authentication.

But I can not create db.
the error is : "Cannot open database "DatabaseNHB" requested by the login. The login failed.
Login failed for user 'fadik-TOSH\fadik'."

What is wrong?
Posted
Updated 20-Dec-10 17:16pm
v3
Comments
Wild-Programmer 20-Dec-10 22:00pm    
Corrected spelling and grammar.

1 solution

It looks like you got your basic connection string right, and the only problematic element is "Database=DatabaseNHB". You need to verify that (1) the database called "DatabaseNHB" exists on your SQL Express server, and that (2) the user 'fadik-TOSH\fadik' is granted access to it. The best way to check this is to log in with the Query Analyzer or SQL Server management studio using Windows Authentication, opening the database called "DatabaseNHB", and running a select on any table defined in that database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900