My application now supports 64-Bit only and I need to get all the ODBC or Access DataSouces present on the machine or newly created one.
Below code was implemented for fetching the List in 32-bit but now it is crashing on calling the SQLAllocEnv
Method.
[DllImport("odbc32.dll")]
private static extern int SQLDataSources(
int EnvHandle, int Direction, StringBuilder ServerName,
int ServerNameBufferLenIn, ref int ServerNameBufferLenOut,
StringBuilder Driver, int DriverBufferLenIn, ref int DriverBufferLenOut);
[DllImport("odbc32.dll")]
private static extern int SQLAllocEnv(ref int EnvHandle);
[DllImport("odbc32.dll")]
private static extern int SQLFreeEnv(int EnvHandle);
So, Do anyone know how to resolve this ?
In some post I found that changing the
int
dataType tolong
will work and Yes, it is working in my case also.