从.NET的ODBC驱动程序列表驱动程序、列表、NET、ODBC

由网友(软趴趴)分享简介:有没有办法让那些安装了.NET中的Windows XP计算机上的ODBC驱动程序的列表? 我基本上希望看到(在.NET)是什么:控制面板 - >管理工具 - >数据源(ODBC) - >驱动程序标签。解决方案 请参阅这或this系统基本上这里存储了ODBC驱动程序的信息HKEY_LOCAL_MACHINE \ SOFT...

有没有办法让那些安装了.NET中的Windows XP计算机上的ODBC驱动程序的列表?

我基本上希望看到(在.NET)是什么:

  

控制面板 - >管理   工具 - >数据源(ODBC) - >驱动程序   标签。

解决方案

请参阅这或this

系统基本上这里存储了ODBC驱动程序的信息 HKEY_LOCAL_MACHINE SOFTWARE ODBC ODBCINST.INI ODBC驱动程序

您可以使用此或类似code,找出所安装的ODBC驱动程序。这code基本上读取注册表中的驱动程序信息

 公共静态列表<字符串> GetSystemDriverList()
        {
            名单<字符串>名称=新的名单,其中,串>();
            //获取系统DSN的
            Microsoft.Win32.RegistryKey章=(Microsoft.Win32.Registry.LocalMachine).OpenSubKey(软件);
            如果(REG!= NULL)
            {
                章= reg.OpenSubKey(ODBC);
                如果(REG!= NULL)
                {
                    章= reg.OpenSubKey(ODBCINST.INI);
                    如果(REG!= NULL)
                    {

                        章= reg.OpenSubKey(ODBC驱动程序);
                        如果(REG!= NULL)
                        {
                            //获取DSN_LOC_IN_REGISTRY定义的所有DSN条目。
                            的foreach(字符串SNAME在reg.GetValueNames())
                            {
                                names.Add(SNAME);
                            }
                        }
                        尝试
                        {
                            reg.Close();
                        }
                        抓{/ *忽略此异常,如果我们不能关闭* /}
                    }
                }
            }

            返回名称;
        }
 
求教.net OdbcDataAdapter.update 用法

Is there a way to get a list of ODBC drivers that are installed on a Windows XP machine from .NET?

I basically would like to see (in .NET) what is in:

Control Panel->Administrative Tools->Data Sources (ODBC)->"Drivers" Tab.

解决方案

See this or this

Basically system stores the ODBC Driver's information here HKEY_LOCAL_MACHINESOFTWAREODBCODBCINST.INIODBC Drivers

You can use this or similar code to find out the installed ODBC Drivers. This code basically reads the drivers info from registry

 public static List<String> GetSystemDriverList()
        {
            List<string> names = new List<string>();
            // get system dsn's
            Microsoft.Win32.RegistryKey reg = (Microsoft.Win32.Registry.LocalMachine).OpenSubKey("Software");
            if (reg != null)
            {
                reg = reg.OpenSubKey("ODBC");
                if (reg != null)
                {
                    reg = reg.OpenSubKey("ODBCINST.INI");
                    if (reg != null)
                    {

                        reg = reg.OpenSubKey("ODBC Drivers");
                        if (reg != null)
                        {
                            // Get all DSN entries defined in DSN_LOC_IN_REGISTRY.
                            foreach (string sName in reg.GetValueNames())
                            {
                                names.Add(sName);
                            }
                        }
                        try
                        {
                            reg.Close();
                        }
                        catch { /* ignore this exception if we couldn't close */ }
                    }
                }
            }

            return names;
        }

阅读全文

相关推荐

最新文章