1、其实ODBC数据源的信息都在注册表里。
修改这里的东西就行了∶
HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INIHKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI
2、用系统的API也行
首先,你必须声明如下三个外部函数:
FUNCTION integer SQLAllocEnv(ref long henv) LIBRARY "odbc32.dll"
FUNCTION integer SQLFreeEnv(long henv) LIBRARY "odbc32.dll"
FUNCTION integer SQLDataSources(long henv,integer idirection,ref string szdsn,int idsnmax,ref integer idsn,ref string szdesc,integer idescmax,ref integer idesc) library "odbc32.dll"
修改这里的东西就行了∶
HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INIHKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI
2、用系统的API也行
首先,你必须声明如下三个外部函数:
FUNCTION integer SQLAllocEnv(ref long henv) LIBRARY "odbc32.dll"
FUNCTION integer SQLFreeEnv(long henv) LIBRARY "odbc32.dll"
FUNCTION integer SQLDataSources(long henv,integer idirection,ref string szdsn,int idsnmax,ref integer idsn,ref string szdesc,integer idescmax,ref integer idesc) library "odbc32.dll"