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!