This project has moved and is read-only. For the latest updates, please go here.

Getting ODBCException when System.Data.Odbc.OdbcCommand.ExecSQL is called

Feb 10, 2016 at 5:57 PM
Edited Feb 15, 2016 at 9:59 AM
I am using this library in Unity 3D which I understand it's an atypical environment for this project.
To use it in Unity I had to change all the OleDb calls to Odbc in the namespace System.Data.Odbc which is supported in Unity's Mono environment.
After this modification the resulting dll works in Unity meaning that an ODBC connection is opened successfully however I get an OdbcException. This is the stack trace:
System.Data.Odbc.OdbcCommand.ExecSQL (CommandBehavior behavior, Boolean createReader, System.String sql)
System.Data.Odbc.OdbcCommand.ExecuteNonQuery (System.String method, CommandBehavior behavior, Boolean createReader)
System.Data.Odbc.OdbcCommand.ExecuteReader (System.String method, CommandBehavior behavior)
System.Data.Odbc.OdbcCommand.ExecuteReader (CommandBehavior behavior)
System.Data.Odbc.OdbcCommand.ExecuteReader ()
(wrapper remoting-invoke-with-check) System.Data.Odbc.OdbcCommand:ExecuteReader ()
Catfood.Shapefile.Shapefile.OpenDb ()
Catfood.Shapefile.Shapefile.Open (System.String path)
Catfood.Shapefile.Shapefile..ctor (System.String path, System.String connectionStringTemplate)
ShapeFileTest.Start () (at Assets/DataReadingAndRendering/fwdtestgisdata/ShapeFileTest.cs:23)
I debugged the selectString variable at line 289 in the current version of the source code and it prints as
SELECT * FROM [tmp721b5e28]
The string inside square brackets is always different with a constant tmp- prefix.
As a further detail I am using a DSN-less connection string that should point to a shapefile with all its siblings including a dbf. The connection string is
"Driver={{Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)}};DriverID=277;PageTimeout=600;Dbq={0};"
and I am passing the shapefile with its complete path as first parameter in the shapeFile constructor call as per documentation. The shapeFile is definitely found.

I wandered whether you could have some ideas to fix this.
Feb 10, 2016 at 11:59 PM
Sorry, not a lot to go on here and I don't have any experience with Mono database access. I'd guess you need to experiment with the connection string. Sorry I can't be of more help.