jueves, 12 de septiembre de 2013

.NET - Relalizar una conexión a Oracle

using System.Data.OracleClient;

 string cadenaConexion = string.Empty;
            string cadenaActualizacion = string.Empty;
            OracleConnection oCon = null;
            OracleDataAdapter MiAdapter = new OracleDataAdapter();
            OracleCommand myCMD = null;

 cadenaConexion = @"USER ID=xxx;DATA SOURCE=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1234))(CONNECT_DATA=(SERVICE_NAME=xxx)));PASSWORD=xxx;PERSIST SECURITY INFO=true;";
            oCon = new OracleConnection(cadenaConexion);
           
            //SOHNUM_0 , FECHA
            //SO011302097 , 21/02/2013
            //'31/12/1599' es fecha nula
            cadenaActualizacion = @"select sohnum_0 , MAX(zfecfradat_0) as FECHA
                                                    from sorderq
                                                    where invflg_0 = 1 and zfecfradat_0 <> '31/12/1599'
                                                    group by sohnum_0";

            myCMD = new OracleCommand(cadenaActualizacion, oCon);
            MiAdapter = new OracleDataAdapter(myCMD);
            dtOracle = new DataTable();
            oCon.Open();
            MiAdapter.Fill(dtOracle);
            oCon.Close();

No hay comentarios:

Publicar un comentario