【问题标题】:C# ODBC DialogC# ODBC 对话框
【发布时间】:2008-09-15 16:46:01
【问题描述】:

关于如何显示 ODBC 连接对话框并取回所选 ODBC 的任何信息?

【问题讨论】:

    标签: c# odbc dialog


    【解决方案1】:
    // a_RootKey is Microsoft.Win32.RegistryKey 
    // DSN is a class not provided in this code sample - you can see what properties are needed from the usage below.
    
    List<DSN> DsnList = new List<DSN>();
    
    Microsoft.Win32.RegistryKey SearchKey = a_RootKey.OpenSubKey("SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources");
    
    if (SearchKey != null)
    {
    
        foreach (string DsnName in SearchKey.GetValueNames() )
        {    
            if ( (string)SearchKey.GetValue(DsnName) == "SQL Server" )
            {
                Microsoft.Win32.RegistryKey anotherkey  = a_RootKey.OpenSubKey("SOFTWARE\\ODBC\\ODBC.INI\\" + DSNName);
                DSN dsn = new DSN();
                dsn.Name = DSNName;
                dsn.Server = (string)anotherkey.GetValue("Server");
                dsn.Database = (string)anotherkey.GetValue("Database");
                dsn.Driver = (string)anotherkey.GetValue("Driver");
    
                DsnList.Add(dsn);
            }
    
        }
    }
    return DsnList;
    

    【讨论】:

      【解决方案2】:

      好的,因为似乎没有人有答案,如何通过 DBSource 遍历 ODBC 连接,即SQLServer 或 MySQL

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-06-17
        • 2013-01-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-02
        相关资源
        最近更新 更多