Home -
General /
All posts - Error when connecting to map file from c# application using ODBC
|
Hi All, I'm trying to connect to an existing map file from a c# console application using the ODBC driver that comes with version 9 (https://manifold.net/doc/mfd9/manifold_odbc_driver.htm) When trying to connect to the data source I get the following error: ERROR [IM004] [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed Is anyone aware of a better way to connect to Manifold from C#? or has dealt with a similar issue? Essentially we just want to be able to query the results of data within Manafold to serve up to another application. Thanks
|
|
Can you provide details on *how* you are connecting from the console app?
|
|
Hi, Currently trying to connect to the following (which works for other ODBC sources) OdbcConnection DbConnection = new OdbcConnection("DSN=<ManifoldODBCSourceICreated>"); DbConnection.Open(); I've also tried using it in the following way: var filePath = "<pathToMapFile>"; var connectionString = "DRIVER={Manifold 9.0 Project Driver (*.map)};DBQ=" + filePath + ";Unicode=True;DSN=Default;"; OdbcConnection DbConnection = new OdbcConnection(connectionString); DbConnection.Open(); Both give the same error (but am able to open other odbc sources such as sqlite just fine) Thanks
|
|
can you connect to the DSN via another method, like excel, mfd8, another dbclient?
|
|
I am able to use it as a data source in Manifold itself (essentially opening another map file as a data source, so I believe that the DSN itself is working) Thanks
|
|
Does the main function in the C# app has the STAThread attribute applied? If not, apply it. Also, you don't have to use the ODBC driver to get to data using Manifold from .NET code. You can add EXTNET.DLL as a reference, create a Root object, then open the desired file (eg, using Application.CreateDatabaseForFile), etc. The main function will have to have the STAThread attribute as well.
|
|
Thanks, adding the attribute fixed the problem and I will investigate using the extnet.dll directly. Thanks
|