Oracle 未使用 .Net 4.0 连接到远程服务器

本文关键字:服务器 连接 未使用 Net Oracle | 更新日期: 2023-09-27 17:57:19

我从测试服务器连接到oracle数据库时遇到问题。波纹管是我的代码片段。

             using Oracle.DataAccess.Client;
             using Oracle.DataAccess.Types;
             private static string GetConnectionString()
     {
    String connString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=IP_Address)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Service_Name)));User Id=hook;Password=Password;";
    return connString;
}
    private string ConnectingToOracle()
     {  
    string connectionString = GetConnectionString();
    using (OracleConnection connection = new OracleConnection())
        try
        {
            connection.ConnectionString = connectionString;
            connection.Open();
            OracleCommand command = connection.CreateCommand();
            string sql = " select * from sgmp.web_portal1   where account_no= '" + customerIdField.Value.ToString().Trim() + "'";
            command.CommandText = sql;
            OracleDataReader reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Session["ClientName"] = (string)reader["Customer_Name"];
                    return (string)reader["Customer_Name"];
                }
            }
            else
            {
                resp.Text = "Client ID '" + customerIdField.Value.ToString().Trim() + "' does not exist in records";
                return "none";
            }

            return "none";
        }
        catch (OracleException ex)
        {
            resp.Text = ex.Message + " reasons ..";
            return "mmm";
        }
}

什么也没得到例外,我不能只是连接。问候。毕竟,我第一次使用甲骨文。

Oracle 未使用 .Net 4.0 连接到远程服务器

我在这里找到了解决方案: http://support.microsoft.com/kb/255084 我需要做的就是步骤 1 到 5