-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem reading/writing .mdb (MS Access) database...
PostPosted: Tue Oct 25, 2005 12:08 am 
Newbie

Joined: Thu Mar 24, 2005 11:29 pm
Posts: 14
I'm a veteran Hibernate programmer in Java, but now I'm play around with C# and I need a way to connect to a local .mdb file. Here's my setup:

1) local .mdb file with a table "test" with cols ID (text) and Text (text).

2) Here's my App.config setup:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>
      <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
   </configSections>
   <nhibernate>
      <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
      <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql7Dialect, NHibernate" />
      <add key="hibernate.connection.driver_class" value="NHibernate.Driver.OleDbDriver, NHibernate" />
      <add key="hibernate.connection.connection_string" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb;User Id=admin;Password=;" />
   </nhibernate>
</configuration>


3) Here's the Test class:

Code:
   public class Test
   {
      public string text;
      public string Text
      {
         get{ return text; }
         set{ text = value; }
      }

      public string id;
      public string ID
      {
         get{ return id; }
         set{ id = value; }
      }


      public Test()
      {
         
      }
   }


4) Here's the Test.hbm.xml, which's embedded:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="SIBL_Admin.Test, SIBL Admin" table="test">
      <id name="ID" column="LogonId" type="String" length="20">
         <generator class="native" />
      </id>

      <property name="Text" type="String"/>
   </class>
</hibernate-mapping>


5) And here's main():

Code:
      [STAThread]
      static void Main()
      {
//         SplashScreen.ShowSplashScreen();
//         Application.DoEvents();
//         Application.Run(new MainForm());

         Configuration cfg = new Configuration();
         cfg.AddAssembly("SIBL Admin");
         ISessionFactory factory = cfg.BuildSessionFactory();
         ISession session = factory.OpenSession();
         ITransaction transaction = session.BeginTransaction();

         MessageBox.Show( session.CreateQuery("from Test").List()[0].ToString() );

         transaction.Commit();
         session.Close();
      }


It connects just fine but whenever I try doing a query.list or session.save on an object, it tells me my SQL syntax is invalid (simply "syntax near INSERT INTO is invalid")... i really hate M$ for their description-less messages.

Can somebody suggest something? I'm guessing my dialect/drivers aren't set up properly. Thank you so much!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 4:40 pm 
Newbie

Joined: Thu Mar 24, 2005 11:29 pm
Posts: 14
I nailed the problem down to this:

Code:
2005-10-25 13:37:10,625 [2704] DEBUG NHibernate.SQL - INSERT INTO test (Bubba) VALUES (?); select @@identity
2005-10-25 13:37:14,656 [2704] DEBUG NHibernate.Util.ADOExceptionReporter - could not insert: [SIBL_Admin.Test]
System.Data.OleDb.OleDbException: Characters found after end of SQL statement.


So I'm guessing it's all about the dialect. Seriously, isn't there an MS Access diaelct?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 4:46 pm 
Newbie

Joined: Thu Mar 24, 2005 11:29 pm
Posts: 14
Well I guess I'm screwed

http://nhibernate.sourceforge.net/forum ... 000dialect


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 4:57 pm 
Have you made any progress in this area. I am experiencing the same problems with access. I have no problems with retrieving data, but I cannot update nor insert data.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.