【问题标题】:Enumerating Oracle Database names for a specified server枚举指定服务器的 Oracle 数据库名称
【发布时间】:2015-01-29 16:58:28
【问题描述】:

如何在 C# 中枚举 Oracle 数据库名称?

我能够查询所有可用的数据库以获取 MSSQL 连接字符串:

using (var con = new SqlConnection("Password=TestPassword;User ID=TestUser;Data Source=localhost"))
{
    con.Open();

    return con.GetSchema("Databases")
                .Rows.Cast<DataRow>()
                .Select(row => row.Field<string>("database_name"))
                .ToList();
}

【问题讨论】:

  • Every oracle db instance has only One database,在这种情况下它与MS SQL Server完全不同
  • 一些有用的阅读asktom.oracle.com/pls/apex/…

标签: c# sql oracle


【解决方案1】:

如果您使用的是 ODP.NET,则可以使用 OracleDataSourceEnumerator 列出 TNS 条目。请参阅文档here

如果没有,那么您将不得不parse the tnsnames.ora yourself

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多