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


C# OracleParameter.Dispose方法代码示例

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


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

示例1: StatementCacheTest

        public static void StatementCacheTest(int iterations)
        {
            // used to track execution duration
            DateTime timeStart;
            DateTime timeEnd;
            double totalSeconds;

            // the connection object to use for the test
            OracleConnection con = new OracleConnection(with_cache);
            con.Open();

            // the command object used for no caching test
            // initial test does not use statement caching
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = con;
            cmd.AddToStatementCache = false;
            cmd.CommandText = "select mensaje from gen_mensajes where id = :1";

            // parameter object for the bind variable
            OracleParameter p_id = new OracleParameter();
            p_id.OracleDbType = OracleDbType.Decimal;
            p_id.Value = 1;

            // add parameter to the collection for the command object
            cmd.Parameters.Add(p_id);

            // the data reader for this test
            OracleDataReader dr;

            // display simple prompt text
            Console.WriteLine("Beginning Statement Cache Test with {0} iterations...", iterations.ToString());

            // capture test start time for no caching test
            timeStart = DateTime.Now;

            // loop creating a connection with no statement caching
            // number of loops is determined by the iterations parameter
            for (int i = 0; i < iterations; i++) {
                dr = cmd.ExecuteReader();
                dr.Read();
                dr.Dispose();
            }

            // capture test end time for no pooling test
            timeEnd = DateTime.Now;

            // calculate total seconds for this test
            totalSeconds = timeEnd.Subtract(timeStart).TotalSeconds;

            // display time used for no caching test
            Console.WriteLine("    No Statement Caching: {0} total seconds.", totalSeconds.ToString());

            // create new command object used for caching test
            cmd.Parameters.Clear();
            cmd.Dispose();
            cmd = new OracleCommand();
            cmd.Connection = con;
            cmd.AddToStatementCache = true;
            //cmd.CommandText = "select data from fetch_test where id = :1";
            cmd.CommandText = "select mensaje from gen_mensajes where id = :1";

            // add parameter to the collection for the command object
            cmd.Parameters.Add(p_id);

            // capture test start time for pooling test
            timeStart = DateTime.Now;

            // loop creating a connection with statement caching
            // number of loops is determined by the iterations parameter
            for (int i = 0; i < iterations; i++) {
                dr = cmd.ExecuteReader();
                dr.Read();
                dr.Dispose();
            }

            // capture test end time for caching test
            timeEnd = DateTime.Now;

            // calculate total seconds for this test
            totalSeconds = timeEnd.Subtract(timeStart).TotalSeconds;

            // display time used for caching test
            Console.WriteLine("  With Statement Caching: {0} total seconds.", totalSeconds.ToString());
            Console.WriteLine();

            // clean up objects
            p_id.Dispose();
            cmd.Dispose();
            con.Dispose();
        }
开发者ID:hdiazvertical,项目名称:PerformanceOracle,代码行数:90,代码来源:Program.cs

示例2: imgReceive_Click


//.........这里部分代码省略.........
                    + "L_RECEIPT_NUM, "
                    + LC_orgid + ", "
                    + supp + ", "
                    + poid + ", "
                    + polineid + ", "
                    + qty + ", "
                    + "'" + lotnum + "'" + ", "
                    + "'" + lpnnum + "'"
                    + ");"
                    + " DBMS_OUTPUT.PUT_LINE('Error Buf is '        || L_ERRBUF);"
                    + " DBMS_OUTPUT.PUT_LINE('Return Code is ' || L_RETCODE);"
                    + " DBMS_OUTPUT.PUT_LINE('Receipt Num ' || L_RECEIPT_NUM);"
                    + "END;";
                Debug.Write(stored_procedure);
                string anonymous_block = "BEGIN "
                    + "DBMS_OUTPUT.GET_LINES(:1, :2); "
                    + "END;";
                // used to indicate number of lines to get during each fetch
                const int NUM_TO_FETCH = 4;

                // used to determine number of rows fetched in anonymous pl/sql block
                int numLinesFetched = 0;

                // simple loop counter used below
                int i = 0;

                // create command and execute the stored procedure
                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = stored_procedure;
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();

                // create parameter objects for the anonymous pl/sql block
                OracleParameter p_lines = new OracleParameter("", OracleDbType.Varchar2, NUM_TO_FETCH, "", ParameterDirection.Output);

                p_lines.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                p_lines.ArrayBindSize = new int[NUM_TO_FETCH];

                // set the bind size value for each element
                for (i = 0; i < NUM_TO_FETCH; i++)
                {
                    p_lines.ArrayBindSize[i] = 32000;
                }

                // this is an input output parameter...
                // on input it holds the number of lines requested to be fetched from the buffer
                // on output it holds the number of lines actually fetched from the buffer
                OracleParameter p_numlines = new OracleParameter("", OracleDbType.Decimal, "", ParameterDirection.InputOutput);

                // set the number of lines to fetch
                p_numlines.Value = NUM_TO_FETCH;

                // set up command object and execute anonymous pl/sql block
                cmd.CommandText = anonymous_block;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(p_lines);
                cmd.Parameters.Add(p_numlines);
                cmd.ExecuteNonQuery();

                // get the number of lines that were fetched (0 = no more lines in buffer)
                numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();

                // as long as lines were fetched from the buffer...
                while (numLinesFetched > 0)
                {
                    // write the text returned for each element in the pl/sql
                    // associative array to the console window
                    for (i = 0; i < 1; i++)
                    {
                        Debug.WriteLine(i);
                        errbuff = (p_lines.Value as OracleString[])[1].ToString();
                        retcode = (p_lines.Value as OracleString[])[2].ToString();
                        recnum = (p_lines.Value as OracleString[])[3].ToString().Remove(0,12);
                    }

                    // re-execute the command to fetch more lines (if any remain)
                    cmd.ExecuteNonQuery();

                    // get the number of lines that were fetched (0 = no more lines in buffer)
                    numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();
                }

                // clean up
                p_numlines.Dispose();
                p_lines.Dispose();
                cmd.Dispose();
                //MessageBox.Show("RECEIPT SUCCESSFUL. RECEIPT NUMBER IS: " + recNum);
                showmsg("TRANSACTION SUCCESSFUL<br /><br />RECEIPT NUMBER <strong>" + recnum + "</strong>");
            }
            catch (OracleException ex)
            {
                Debug.WriteLine("Exception Message: " + ex.Message);
                Debug.WriteLine("Exception Source: " + ex.Source);
                //MessageBox.Show("RECEIPT UNSUCCESSFUL. RETURN CODE IS: " + retcode + " AND ERROR IS: " + errbuff);
                showmsg("TRANSACTION FAILED<br /><br />RETURN CODE <strong>" + retcode + "</strong> ERROR <strong>" + errbuff + "</strong>");
            }
        }

        Page_Load(null, null);
    }
开发者ID:r1chjames,项目名称:CSEBSFrontEnd,代码行数:101,代码来源:Goods_In_2.aspx.cs

示例3: ShowResultSet

        void ShowResultSet(OracleDataReader reader, OracleCommand command)
        {
            //it is included dbms_output
            command.CommandText = "begin dbms_output.enable (32000); end;";
            command.CommandType = CommandType.Text;
            command.ExecuteNonQuery();

            bool headerPrinted = false;
            int count = 1;
            while (reader.Read())
            {
                if (!headerPrinted)
                {
                    Console.WriteLine(@"<table class=""sqloutput""><tbody><tr><th>&nbsp;&nbsp;</th>");
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        string name = reader.GetName(i);
                        Console.WriteLine(@"<th>{0}</th>", string.IsNullOrEmpty(name) ? "(No column name)" : name);
                    }
                    Console.WriteLine("</tr>");
                    headerPrinted = true;
                }
                Console.WriteLine(@"<tr><td>{0}</td>", count++);
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    if (reader[i] == DBNull.Value)
                    {
                        Console.WriteLine(@"<td><i>NULL</i></td>");
                    }
                    else
                    {
                        if (reader[i] as string == null && reader[i] as IEnumerable != null)
                        {
                            string res = "";
                            foreach (var a in (reader[i] as IEnumerable))
                                res += Convert.ToString(a);
                            Console.WriteLine(@"<td>{0}</td>", res);
                        }
                        else
                        {
                            Console.WriteLine(@"<td>{0}</td>", HttpUtility.HtmlEncode(reader[i]));
                        }
                    }
                }
                Console.WriteLine("</tr>");
            }
            if (headerPrinted)
                Console.WriteLine("</tbody></table>");

            // create parameter objects for the anonymous pl/sql block
            int NUM_TO_FETCH = 8;
            OracleParameter p_lines = new OracleParameter("", OracleDbType.Varchar2, NUM_TO_FETCH, "", ParameterDirection.Output);
            p_lines.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
            p_lines.ArrayBindSize = new int[NUM_TO_FETCH];
            // set the bind size value for each element
            for (int i = 0; i < NUM_TO_FETCH; i++)
            {
                p_lines.ArrayBindSize[i] = 32000;
            }

            // this is an input output parameter...
            // on input it holds the number of lines requested to be fetched from the buffer
            // on output it holds the number of lines actually fetched from the buffer
            OracleParameter p_numlines = new OracleParameter("", OracleDbType.Decimal, "", ParameterDirection.InputOutput);
            // set the number of lines to fetch
            p_numlines.Value = NUM_TO_FETCH;
            // set up command object and execute anonymous pl/sql block
            command.CommandText = "begin dbms_output.get_lines(:1, :2); end;";
            command.CommandType = CommandType.Text;
            command.Parameters.Add(p_lines);
            command.Parameters.Add(p_numlines);
            command.ExecuteNonQuery();

            // get the number of lines that were fetched (0 = no more lines in buffer)
            int numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();

            // as long as lines were fetched from the buffer...
            while (numLinesFetched > 0)
            {
                // write the text returned for each element in the pl/sql
                // associative array to the console window
                for (int i = 0; i < numLinesFetched; i++)
                {
                    string out_string = (string)(p_lines.Value as OracleString[])[i];
                    if (!string.IsNullOrEmpty(out_string))
                    {
                        Console.WriteLine(System.Web.HttpUtility.HtmlEncode(out_string));
                    }
                }

                // re-execute the command to fetch more lines (if any remain)
                command.ExecuteNonQuery();
                // get the number of lines that were fetched (0 = no more lines in buffer)
                numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();
            }
            // clean up

            p_numlines.Dispose();
            p_lines.Dispose();
        }
开发者ID:ren85,项目名称:rextester_win,代码行数:100,代码来源:Program.cs

示例4: generate_LPN

    protected void generate_LPN(string org_id)
    {
        using (OracleConnection conn = new OracleConnection())
        {
            try
            {
                conn.ConnectionString = EBSDM13A;
                conn.Open();
                string stored_procedure = "DECLARE "
                    + "p_lpn_id NUMBER; "
                    + "p_lpn_number VARCHAR2(50); "
                    + "BEGIN "
                    + "DBMS_OUTPUT.ENABLE; "
                    + "xxpoc_goods_in.create_lpn(" + org_id + ", p_lpn_id, p_lpn_number); "
                    + "DBMS_OUTPUT.PUT_LINE(p_lpn_number); "
                    + "END;";
                string anonymous_block = "BEGIN "
                    + "DBMS_OUTPUT.GET_LINES(:1, :2); "
                    + "END;";
                // used to indicate number of lines to get during each fetch
                const int NUM_TO_FETCH = 1;

                // used to determine number of rows fetched in anonymous pl/sql block
                int numLinesFetched = 0;

                // simple loop counter used below
                int i = 0;

                // create command and execute the stored procedure
                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = stored_procedure;
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();

                // create parameter objects for the anonymous pl/sql block
                OracleParameter p_lines = new OracleParameter("", OracleDbType.Varchar2, NUM_TO_FETCH, "", ParameterDirection.Output);

                p_lines.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                p_lines.ArrayBindSize = new int[NUM_TO_FETCH];

                // set the bind size value for each element
                for (i = 0; i < NUM_TO_FETCH; i++)
                {
                    p_lines.ArrayBindSize[i] = 32000;
                }

                // this is an input output parameter...
                // on input it holds the number of lines requested to be fetched from the buffer
                // on output it holds the number of lines actually fetched from the buffer
                OracleParameter p_numlines = new OracleParameter("", OracleDbType.Decimal, "", ParameterDirection.InputOutput);

                // set the number of lines to fetch
                p_numlines.Value = NUM_TO_FETCH;

                // set up command object and execute anonymous pl/sql block
                cmd.CommandText = anonymous_block;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(p_lines);
                cmd.Parameters.Add(p_numlines);
                cmd.ExecuteNonQuery();

                // get the number of lines that were fetched (0 = no more lines in buffer)
                numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();

                // as long as lines were fetched from the buffer...
                while (numLinesFetched > 0)
                {
                    // write the text returned for each element in the pl/sql
                    // associative array to the console window
                    for (i = 0; i < 1; i++)
                    {
                        lpnnum = (p_lines.Value as OracleString[])[0].ToString();
                        txtBoxLPN.Text = lpnnum;
                        ViewState["VS_lpnnum"] = lpnnum;
                    }

                    // re-execute the command to fetch more lines (if any remain)
                    cmd.ExecuteNonQuery();

                    // get the number of lines that were fetched (0 = no more lines in buffer)
                    numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();
                }

                // clean up
                p_numlines.Dispose();
                p_lines.Dispose();
                cmd.Dispose();
            }
            catch (OracleException ex)
            {
                Debug.WriteLine("Exception Message: " + ex.Message);
                Debug.WriteLine("Exception Source: " + ex.Source);
            }
        }
    }
开发者ID:r1chjames,项目名称:CSEBSFrontEnd,代码行数:95,代码来源:Goods_In_2.aspx.cs

示例5: EjecutarDLLOracle

        private void EjecutarDLLOracle(String tipo)
        {
            string objeto = comboBoxDDL.SelectedItem.ToString();
            using (OracleConnection oraConn = new OracleConnection("data source=" + orc.database + ";user id=" + orc.user + ";password=" + orc.contrasennia))
            {
                oraConn.Open();

                using (OracleCommand cmd = new OracleCommand())
                {
                    cmd.Connection = oraConn;
                    cmd.CommandText = "dbms_metadata.get_ddl";
                    cmd.CommandType = CommandType.StoredProcedure;

                    OracleParameter clobparam = new OracleParameter();
                    clobparam.OracleDbType = OracleDbType.Clob;
                    clobparam.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(clobparam);

                    OracleParameter parmObjectType = new OracleParameter();
                    parmObjectType.OracleDbType = OracleDbType.Varchar2;
                    parmObjectType.ParameterName = "OBJECT_TYPE";
                    parmObjectType.Value = tipo;
                    cmd.Parameters.Add(parmObjectType);

                    OracleParameter parmObjectName = new OracleParameter();
                    parmObjectName.OracleDbType = OracleDbType.Varchar2;
                    parmObjectName.ParameterName = "NAME";
                    parmObjectName.Value = objeto;
                    cmd.Parameters.Add(parmObjectName);

                    OracleParameter parmObjectOwner = new OracleParameter();
                    parmObjectOwner.OracleDbType = OracleDbType.Varchar2;
                    parmObjectOwner.ParameterName = "SCHEMA";
                    parmObjectOwner.Value = orc.user.ToUpper();
                    cmd.Parameters.Add(parmObjectOwner);

                    cmd.ExecuteNonQuery();

                    this.cuadroMostrarDDL.Text = (((Oracle.DataAccess.Types.OracleClob)clobparam.Value).Value);

                    clobparam.Dispose();
                }
            }
        }
开发者ID:ChichisForever,项目名称:Proyecto1Bases2,代码行数:44,代码来源:Administrador.cs


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