-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: SQL CE trable
PostPosted: Mon Apr 23, 2007 8:36 am 
Newbie

Joined: Mon Apr 23, 2007 8:19 am
Posts: 1
Hay. I'm try to use NHibernate in VS 2005. I have succsesfull connection on SQL Express 2005 DB. Then I try connect to CE Mobile (SQL 3.0 Mobile) database and NHibernate show me error - Could not create the driver from NHibernate.Driver.SqlServerCeDriver

My files and code list below:

Error

Code:
NHibernate.HibernateException was unhandled
  Message="Could not create the driver from NHibernate.Driver.SqlServerCeDriver."
  Source="NHibernate"
  StackTrace:
       at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary settings)
       at NHibernate.Connection.ConnectionProvider.Configure(IDictionary settings)
       at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary settings)
       at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary properties)
       at NHibernate.Cfg.Configuration.BuildSettings()
       at NHibernate.Cfg.Configuration.BuildSessionFactory()



hibernate.cfg.xml

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <!--  an ISessionFactory instance -->
  <session-factory>
    <!--   properties  -->
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
    <property name="connection.connection_string">Data Source ='C:\Temp\SimpleDB.sdf'; Password='simple'</property>
    <property name="show_sql">false</property>
    <property name="dialect">NHibernate.Dialect.MsSqlCeDialect</property>
    <property name="use_outer_join">true</property>
    <!--   mapping files  -->
    <mapping assembly="MyNHib" />
  </session-factory>
</hibernate-configuration>


User.hbm.xml

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyNHib" namespace="MyNHib">
<class name="MyNHib.User" table="users">
<id name="Id" column="LogonId" type="String" length="20">
  <generator class="assigned" />
  </id>
  <property name="UserName" column="Name" type="String" length="40" />
  <property name="Password" type="String" length="20" />
  <property name="EmailAddress" type="String" length="40" />
  <property name="LastLogon" type="DateTime" />
  </class>
  </hibernate-mapping>




Program.cs

Code:
....
ISessionFactory session =
   new Configuration().Configure().BuildSessionFactory();

   ISession sess = session.OpenSession();
   User usr = new User();
   usr.Id = "1";
         usr.UserName = "Name";
         usr.Password = "Pssw";
         usr.EmailAddress = "e@mail";
         usr.LastLogon = DateTime.Now;

         sess.Save(usr);
         sess.Flush();
         sess.Close();
...


How connect on SQL CE Mobile?

P.S. sorry my poor English.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 3:57 am 
Newbie

Joined: Fri Aug 03, 2007 3:47 am
Posts: 1
Hi,

I saw your post while I was struggling with the same problem using Castle Project ActiveRecord that uses NHibernate. Sadly, there were no reply to your post.

However, I found out that if your System.Data.SqlServerCe is NOT in the GAC the corresponding DLL (System.Data.SqlServerCe.dll) must be located in the same folder as your application's DLL's and executables.

This can be easily achieved by setting the 'Copy Local' attribute of the reference to System.Data.SqlServerCe to 'True' in your .NET project settings.

I hope this helps even if it has been some time since your post.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.