0

我的应用程序现在仅支持 64 位,我需要获取机器上或新创建的所有 ODBC 或 Access DataSouces。

下面的代码是为获取 32 位列表而实现的,但现在它在调用SQLAllocEnv方法时崩溃。

[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);

那么,有谁知道如何解决这个问题?

4

1 回答 1

0

在某些帖子中,我发现将intdataType 更改为long将起作用,是的,它也适用于我的情况。

于 2018-09-17T07:58:01.947 回答