Skip to main content
7 de 9
se eliminaron 9 caracteres en el cuerpo
Luciano Montañez
  • 2.5k
  • 2
  • 10
  • 23

En un principio te recomiendo que quites las referencias de

System.Data.OracleClient;

y luego instales el conector de oracle

Install-Package Oracle.ManagedDataAccess -Version 12.2.1100

Luego que cambies el Connection String de esta forma

        const string _protocol = "TCP";
        const string _schema = "xx";
        const string _pswSchema = "xx";
        const string _host = "xx";
        const string _port = "1521";
        const string _serviceName = "xx";

        const string _cnnString = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=" + _protocol + ")(HOST=" + _host + ")"
                             + "(PORT=" + _port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + _serviceName + ")))";

Luego en tu código

    using Oracle.ManagedDataAccess.Client;
    
    //
    var oracleConnectionStringBuilder = new OracleConnectionStringBuilder
            {
                DataSource = _cnnString,
                UserID = _schema ,
                Password = _pswSchema 
            };

    string cnnStringFormat2 = "Data Source=" + _cnnString + ";User Id="+ _schema + ";Password="+ _pswSchema ;
    OracleConnection con = new OracleConnection(oracleConnectionStringBuilder.ToString());
    OracleCommand oracommand = new OracleCommand("get_secuencia",con);
    OracleDataReader lector;
       
    try
    {
       con.Open();
       oracommand.Parameters.Add("consec", Oracle.ManagedDataAccess.Client.OracleDbType.Int32).Direction = ParameterDirection.Output;
       oracommand.ExecuteNonQuery();
       LNumDoc.Text = (string)(oracommand.Parameters["consec"].Value);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "XXXX.");
    }
    con.Close();
Luciano Montañez
  • 2.5k
  • 2
  • 10
  • 23