当前位置: 首页>>代码示例>>C#>>正文


C# OracleConnection.Dispose方法代码示例

本文整理汇总了C#中Oracle.DataAccess.Client.OracleConnection.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# OracleConnection.Dispose方法的具体用法?C# OracleConnection.Dispose怎么用?C# OracleConnection.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oracle.DataAccess.Client.OracleConnection的用法示例。


在下文中一共展示了OracleConnection.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestConnection

        /// <summary>
        /// Metodo utilizado para validad la conexion a una base de datos Oracle
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool TestConnection(string username, string password)
        {
            this.username = username;
            this.password = password;

            string[] parametrosConnectionString = CadenaConexion.Split(';');
            
            var dataSourceEncontrado = CadenaConexion.ToUpper().Split(';').FirstOrDefault(c => c.Contains("DATA SOURCE"));
            DataSource = dataSourceEncontrado.Substring(dataSourceEncontrado.IndexOf("DATA SOURCE") + 12);
            
            CadenaConexion = ConstruirCadenaConexion(parametrosConnectionString);

            //Se agrego referencia Oracle.DataAccess.Client para framework 4
            using (OracleConnection oracle = new OracleConnection())
            {
                try
                {
                    var CadenaConexion1 = string.Format("Data Source={0}; User Id={1}; Password={2}; Pooling=true; Min Pool Size=1; Max Pool Size=2; Connection Timeout=30", DataSource, Username, Password);
                    oracle.ConnectionString = CadenaConexion1;
                    oracle.Open();
                    return true;
                }
                catch
                {
                    return false;
                }
                finally 
                {
                    oracle.Close();
                    oracle.Dispose();
                }
            }
        }
开发者ID:uvillazon,项目名称:citytruck,代码行数:39,代码来源:TestOracleConexion.cs

示例2: getAuthForIdUser

        public UsAuth getAuthForIdUser(string email, string passwd)
        {
            OracleConnection connection = null;
            OracleDataReader dr = null;
            UsAuth auth = null;

            try
            {
                using (connection = new OracleConnection(OracleHelper.connectionString()))
                {
                    using (var command = new OracleCommand("US_AUTH_GETFOR_USER", connection))
                    {
                        connection.Open();
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("P_CUR_RESULT", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                        command.Parameters.Add("EMAIL", email);
                        command.Parameters.Add("PASWD", passwd);

                        using (dr = command.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                auth = new UsAuth()
                                {
                                    IdUser = Convert.ToInt32(dr["IDUSER"].ToString()),
                                    Email = dr["EMAIL"].ToString(),
                                    FirstName = dr["FIRSTNAME"].ToString(),
                                    LastName = dr["LASTNAME"].ToString(),
                                    Role = new UsRole()
                                    {
                                        Id = Convert.ToInt32(dr["IDROLE"].ToString()),
                                        Name = dr["NAMEROLE"].ToString()
                                    },
                                    Photo = dr["PHOTO"].ToString(),
                                    ListRoleModule = new DARoleModule().getRoleModuleForRole(Convert.ToInt32(dr["IDROLE"].ToString())),
                                    ListRoleModulePrivilege = new DARoleModulePrivilege().getRoleModulePrivilegeForRole(Convert.ToInt32(dr["IDROLE"].ToString()))
                                };
                            }
                        }
                    }
                }

                return auth;

            }
            catch (Exception e)
            {
                dr.Dispose();

                if (connection.State == ConnectionState.Open)
                    connection.Dispose();

                LogHelper.WriteLog(e);
                throw e;
            }
            finally
            {
                auth = null;
            }
        }
开发者ID:luisrog,项目名称:ACE_CarShop,代码行数:60,代码来源:DAAuth.cs

示例3: RawQuery

        public void RawQuery(String Query)
        {
            OracleConnection conn = new OracleConnection();
            conn.ConnectionString = "User Id=SYSTEM;Password=oracle";

            OracleDataReader rdr;
            try
            {
                conn.Open();
                //OracleCommand cmd = new OracleCommand("select * from employee", conn);
                OracleCommand cmd = new OracleCommand(Query, conn);
                rdr = cmd.ExecuteReader();
                int rdr_size = (int)rdr.VisibleFieldCount;

                int n = 0;
                while (rdr.Read())
                {
                    n = 0;
                    while (n < rdr_size)
                    {
                        Console.Write("{0,-15} ",rdr[n]);
                        n++;
                    }

                    Console.WriteLine();
                }

                conn.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
开发者ID:luquencio,项目名称:storeprocedureexample,代码行数:34,代码来源:Employee.cs

示例4: button1_Click_1

        private void button1_Click_1(object sender, EventArgs e)
        {
            int a;
            a = Convert.ToInt32(textBox4.Text);
            a = int.Parse(textBox4.Text);
            string oradb = "Data Source=XE;User Id=system;Password=admin;";

            OracleConnection conn = new OracleConnection(oradb);

            conn.Open();

            OracleCommand cmd = new OracleCommand();

            cmd.Connection = conn;

            cmd.CommandText = "update pharm.DRUG set QUANTITY =QUANTITY - " + a + "";

            int rowsUpdated = cmd.ExecuteNonQuery();

            if (rowsUpdated == 0)

                MessageBox.Show("Record not inserted");

            else

                MessageBox.Show("Success!");

            conn.Dispose();
        }
开发者ID:vinilprabhu,项目名称:pharmacy_management-,代码行数:29,代码来源:purchase.cs

示例5: buttonupdate_Click

        private void buttonupdate_Click(object sender, EventArgs e)
        {
            string oradb = "Data Source=XE;User Id=system;Password=admin;";

            OracleConnection conn = new OracleConnection(oradb);

            conn.Open();

            OracleCommand cmd = new OracleCommand();

            cmd.Connection = conn;

            cmd.CommandText = "update pharm.DRUG set D_NAME = '" + updatename.Text + "', MFD = '"+ textBox3.Text +"', EXP= '"+ updateexp.Text + "' , COST ="+ updatecost.Text +", QUANTITY =  "+ textBox2.Text + " WHERE DRUG_ID = " + textBox1.Text;

            int rowsUpdated = cmd.ExecuteNonQuery();

            if (rowsUpdated == 0)

                MessageBox.Show("Record not inserted");

            else

                MessageBox.Show("Success!");

            conn.Dispose();
        }
开发者ID:vinilprabhu,项目名称:pharmacy_management-,代码行数:26,代码来源:updateform.cs

示例6: CloseCon

        public static void CloseCon(OracleConnection con)
        {
            con.Close();
            con.Dispose();

            GC.Collect();
        }
开发者ID:oldfox94,项目名称:TPDev.DatabaseFactory,代码行数:7,代码来源:CONNECTION.cs

示例7: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            string oradb = "Data Source=XE;User Id=system;Password=admin;";

            OracleConnection conn = new OracleConnection(oradb);

            conn.Open();

            OracleCommand cmd = new OracleCommand();

            cmd.Connection = conn;

            cmd.CommandText = "Delete from pharm.DRUG where DRUG_ID=" + textBox1.Text + " ";

            int rowsUpdated = cmd.ExecuteNonQuery();

            if (rowsUpdated == 0)

                MessageBox.Show("Record not deleted");

            else

                MessageBox.Show("Successfully deleted!");

            conn.Dispose();
        }
开发者ID:vinilprabhu,项目名称:pharmacy_management-,代码行数:26,代码来源:deleteform.cs

示例8: GetInfo

        public static Employee GetInfo(OracleDataReader reader, DPFP.Sample Sample, string Finger)
        {
            OracleConnection conn = new OracleConnection(ConStr);
            Employee _info = null;
            DPFP.Template _template = null;
            bool IsFound = false;
            if (reader[Finger] != DBNull.Value)
            {
                _template = Util.ProcessDBTemplate((byte[])reader[Finger]);
                IsFound = Util.Verify(Sample, _template);
            }
            if (IsFound == true)
            {
                string sqlEmp = "select * from employees where Empl_Id_No=" + reader["Empl_Id_No"];
                OracleCommand cmd = new OracleCommand(sqlEmp, conn);
                cmd.CommandType = CommandType.Text;
                conn.Open();
                OracleDataReader odr = cmd.ExecuteReader();
                if (odr.HasRows)
                {
                    _info = new Employee();
                    _info.Empl_Id_No = Convert.ToInt32(reader["Empl_Id_No"]);
                    _info.Empl_Name = (string)odr["Empl_Name"];
                    _info.Empl_Deptname = (string)odr["Empl_Deptname"];
                    _info.Shift_Id = Convert.ToInt32(odr["Shift_Id"]);
                }
                odr.Dispose();
                cmd.Dispose();
                conn.Close();
                conn.Dispose();
            }

            return _info;
        }
开发者ID:BGCX262,项目名称:zsicam-svn-to-git,代码行数:34,代码来源:dcEmployee.cs

示例9: CloseConnection

 public static void CloseConnection(OracleConnection connect)
 {
     if (connect == null) return;
     if (connect.State == ConnectionState.Open)
     {
         connect.Close();
     }
     connect.Dispose();
 }
开发者ID:nstungxd,项目名称:ips-project-vdc,代码行数:9,代码来源:ConnectDB.cs

示例10: getRoleForState

        public List<UsRole> getRoleForState(int idState)
        {
            OracleConnection connection = null;
            OracleDataReader dr = null;
            List<UsRole> list = null;

            try
            {
                using (connection = new OracleConnection(OracleHelper.connectionString()))
                {
                    using (var command = new OracleCommand("US_ROLE_GETFOR_STATE", connection))
                    {
                        connection.Open();
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("P_CUR_RESULT", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                        command.Parameters.Add("ID", idState);

                        using (dr = command.ExecuteReader())
                        {
                            list = new List<UsRole>();

                            if (dr.HasRows)
                            {
                                while (dr.Read())
                                {
                                    list.Add(
                                        new UsRole()
                                        {
                                            Id = Convert.ToInt32(dr["ID"].ToString()),
                                            Name = dr["NAME"].ToString()
                                        }
                                    );
                                }
                            }
                        }
                    }
                }

                return list;

            }
            catch (Exception e)
            {
                dr.Dispose();

                if (connection.State == ConnectionState.Open)
                    connection.Dispose();

                LogHelper.WriteLog(e);
                throw e;
            }
            finally
            {
                list = null;
            }
        }
开发者ID:luisrog,项目名称:ACE_CarShop,代码行数:56,代码来源:DARole.cs

示例11: ExecuteListadeSetores

        public static Boolean ExecuteListadeSetores(
           ConnectionInfo pInfo, decimal pSET_ID, string pCHAVE
        )
        {
            Boolean values;

            try
            {
                string lQuery = "";
                DataTable lTable = new DataTable();

                OracleCommand cmd = new OracleCommand();

                using (OracleConnection cn = new OracleConnection(pInfo.ConnectionString))
                {
                    cmd.Connection = cn;
                    cmd.CommandText = "spLista";
                    cmd.CommandType = CommandType.StoredProcedure;

                    //cmd.CommandText = " BEGIN spLista (" + pSET_ID + ", " + pCHAVE + "); END; ";

                    cmd.Parameters.Add("pSET_ID", OracleDbType.Decimal).Value = pSET_ID;
                    cmd.Parameters.Add("pCHAVE", OracleDbType.Decimal).Value = pCHAVE;

                    cn.Open();

                    DataSet ds = new DataSet();
                    OracleDataAdapter Adapter = new OracleDataAdapter(cmd);

                    Adapter.Fill(ds);
                    Adapter.Dispose();
                    values = true;

                    cmd.Dispose();
                    cn.Dispose();
                    cn.Close();
                }
                return values;
            }
            catch (Exception ex)
            {
                values = false;
            }
            return values;
        }
开发者ID:andreibaptista,项目名称:DEF_PUB_DEFNET_PORTAL,代码行数:45,代码来源:SETORXPAIDo.cs

示例12: btnConnectNow_Click

        private void btnConnectNow_Click(object sender, EventArgs e)
        {
            var oracleConnectionStringBuilder = OracleConnectionStringBuilder;

            var oracleConnection = new OracleConnection();
            oracleConnection.ConnectionString = oracleConnectionStringBuilder.ConnectionString;

            try
            {
                oracleConnection.Open();
                oracleConnection.Dispose();
                MessageBox.Show("Connection successful!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error connecting to Oracle");
            }
        }
开发者ID:spolnik,项目名称:LearningOdp.Net,代码行数:18,代码来源:Form1.cs

示例13: ExecuteDataSet

 /// <summary>
 /// 执行一条返回结果集的OracleCommand命令,通过专用的连接字符串。
 /// 使用参数数组提供参数
 /// </summary>
 /// <remarks>
 /// 使用示例:
 /// DateSet ds = ExecuteDataSet(connString, CommandType.StoredProcedure, "PublishOrders", new OracleParameter("@prodid", 24));
 /// </remarks>
 /// <param name="connectionString">一个有效的数据库连接字符串</param>
 /// <param name="cmdType">OracleCommand命令类型 (存储过程, T-Oracle语句, 等等。)</param>
 /// <param name="cmdText">存储过程的名字或者 T-Oracle 语句</param>
 /// <param name="commandParameters">以数组形式提供OracleCommand命令中用到的参数列表</param>
 /// <returns>返回一个包含结果的DataSet</returns>
 public static DataSet ExecuteDataSet(string connectionString, CommandType cmdType, string cmdText, params OracleParameter[] commandParameters)
 {
     OracleCommand cmd = new OracleCommand();
     OracleConnection conn = new OracleConnection(connectionString);
     try
     {
         PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
         OracleDataAdapter adapter = new OracleDataAdapter(cmd);
         DataSet ds = new DataSet();
         adapter.Fill(ds);
         return ds;
     }
     catch { throw; }
     finally
     {
         cmd.Parameters.Clear();
         conn.Dispose();
     }
 }
开发者ID:hhahh2011,项目名称:CH.Gps,代码行数:32,代码来源:DbOracleHelper.cs

示例14: OraclePipeListener

        public OraclePipeListener(string connectionString, string dataBase, string tableName)
        {
            m_DateBase = dataBase;
            m_TableName = tableName;

            m_Connection = new OracleConnection(connectionString);
            m_Connection.Open();

            m_Command = m_Connection.CreateCommand();
            m_Command.CommandText = string.Format("SELECT * FROM {0}.{1} WHERE rownum = 1", DateBase,TableName);

            m_Dependency = new OracleDependency(m_Command);
            m_Dependency.OnChange += new OnChangeEventHandler(DependencyChange);

            m_Command.Notification.IsNotifiedOnce = false;
            m_Command.AddRowid = true;

            m_Command.ExecuteNonQuery();
            m_Connection.Close();
            m_Connection.Dispose();
        }
开发者ID:Beetle-ru,项目名称:NucleusCollaborative,代码行数:21,代码来源:OraclePipeListener.cs

示例15: Fill

        public bool Fill()
        {
            try {
                conn = new OracleConnection(GetConnectionString());
                conn.Open();
                transaction = conn.BeginTransaction();
            } catch (Exception e) {
                MessageBox.Show("При подключении к базе данных произошла ошибка:\n\n" + e.Message);
                conn.Close();
                conn.Dispose();
                return false;
            }

            cmd = conn.CreateCommand();
            cmd.CommandText = "SELECT TO_CHAR(id), l_name from akriko.cat_executors WHERE id in (SELECT distinct(ispolnitel_cik_id) FROM akriko.appeal) ORDER BY UPPER(l_name)";
            try {
                dr = cmd.ExecuteReader();
                while (dr.Read()) {
                    if (dr.IsDBNull(0) || dr.IsDBNull(1)) {
                        MessageBox.Show("При чтении данных из базы данных произошла ошибка:\n\n");
                        break;
                    } else {
                        UsersGrid.Rows.Add();
                        UsersGrid.Rows[UsersGrid.Rows.Count - 1].Cells["executor_id"].Value = dr.GetString(0);
                        UsersGrid.Rows[UsersGrid.Rows.Count - 1].Cells["akriko"].Value = dr.GetString(1);
                    }

                }
                dr.Close();
                dr.Dispose();
            } catch (Exception e) {
                MessageBox.Show("При чтении данных из базы данных произошла ошибка:\n\n" + e.Message);
            }
            if (UsersGrid.Rows.Count == 0) {
                MessageBox.Show("Отсутствуют неотконвертированные исполнители", "Конвертация исполнителей", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ConvertButton.Enabled = false;
            }
            FillDeloDepartmentsColumn();
            return true;
        }
开发者ID:timofeev-denis,项目名称:UserConverter,代码行数:40,代码来源:MainForm.cs


注:本文中的Oracle.DataAccess.Client.OracleConnection.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。