views:

643

answers:

1

Hi,

I've been trying to work out how to connect to an ESRI shape file (which I think is a DBase table file) through NHibernate but haven't had any luck with anything I've tried.

Currently, my config's looking like this:

<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>

<!--<property name="dialect">NHibernate.Dialect.GenericDialect</property>
<property name="connection.driver_class">NHibernate.Driver.OdbcDriver</property>
<property name="connection.connection_string">Database=A303.dbf;protocol=TCPIP</property>-->

<property name="connection.driver_class">NHibernate.Driver.OdbcDriver</property>
<!--<property name="connection.connection_string">driver={IBM DB2 ODBC DRIVER};Database=a303.dbf;protocol=TCPIP</property>-->
<property name="connection.connection_string">Provider=VFPOLEDB.1; Data Source=C:\projects\rm4\Sandbox\bin\Debug\A303.dbf;Extended Properties=dBase III</property>
<property name="dialect">NHibernate.Dialect.DB2Dialect</property>
<property name="use_outer_join">true</property>

<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="show_sql">true</property>

I've left the commented out bits in so you can see what values I've been trying. No matter what I try, I get the error message:

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I've gone through most of the connection string I've found online and in some answers to questions on here was getting to the 'clutching at straws' phase where I'm just putting anything in so thought I'd better ask for help.

I'm not even sure if it's possible to connect to this type of file from NHibernate but, if it is, does anyone know what should be in the config?

Thanks,

K

A: 

I would try a different NHibernate driver. Here is a list of NHibernate drivers from the documentation.

Judging from the provider name in your connection string, I would try NHibernate.Driver.OleDbDriver.

Failing this, I would eliminate NHibernate from the mix and see if you can connect using the standard .NET data classes, such as System.Data.Odbc.OdbcConnection and System.Data.OleDb.OleDbConnection. If you cannot connect at this level, then the problem is not NHibernate.

Mark Glasgow
Hi, sorry for not replying sooner - didn't get an email through about a response. I ended up using the OleDb driver to connect directly to the data and that works okay. It's on the to-do list at the end of the project to convert this to NHibernate so I'll try your suggestion when I'm doing that. Thanks.
Kevin Wilson