问题描述:
通过C#引用Oracle.ManagedDataAccess.dll访问Oracle,写了如下一段代码,在本机能正常访问,但是将编译后的exe放到服务器上面就无法访问了,一直提示登录失败。
而服务器上面的pl/sql却能够正常访问数据库。

static void Main(string[] args)
{
    string connStr=string.Empty;
    try
    {
        connStr = string.Format(@"User Id={3};Password={4};  Data Source=(description=(address_list = (address = (HOST = {0})(PROTOCOL = TCP)(PORT= {1})))(connect_data=(service_name={2})));", "172.23.11.152", "1521", "orcl", "system", "oracle123");
        using (OracleConnection conn = new OracleConnection(connStr))
        {
            OracleCommand comm = new OracleCommand("select count(1) from wifi.site_info", conn);
            conn.Open();
            object a = comm.ExecuteScalar();
            conn.Close();

            Console.WriteLine(a);
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
        Console.WriteLine("连接字符串:" + connStr);
    }

    Console.Read();
}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-12-28
  • 2021-08-09
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-02
  • 2021-04-05
  • 2021-12-26
  • 2021-06-13
  • 2021-07-16
相关资源
相似解决方案