我的应用程序现在只支持64位,我需要获取机器上或新创建的所有ODBC或Access DataSouces。
下面的代码实现了以32位获取List,但现在它在调用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);
那么,有谁知道如何解决这个问题?
在一些帖子中,我发现将int
dataType更改为long
将起作用,是的,它也适用于我的情况。