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


C# OracleConnection.CreateCommand方法代码示例

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


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

示例1: TestConnectionWithString

        public void TestConnectionWithString() 
        {
            int ret = 0;
            string connstring = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=pdborcl)));User Id=system;Password=admin1234;";

            string sql = @"select *from user_tables;";
            sql = getSqlString();
//            string sql = @"begin 
//create sequence TABLE22_SEQ;
//create table table22(id NUMBER DEFAULT 1);
//end;";
            using (DbConnection conn = new  OracleConnection(connstring))
            {
                conn.Open();
                DbCommand command = conn.CreateCommand();
                command.CommandType = CommandType.Text;
                command.CommandText = sql;

                ret = command.ExecuteNonQuery();

                conn.Close();
            }

            Assert.AreNotEqual(ret,0);
        }
开发者ID:Aliceljm1,项目名称:kiss-project.linq,代码行数:25,代码来源:EntryPoint.cs

示例2: ADO_NET_Example

        static void ADO_NET_Example()
        {
            var cs = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=www.machinejar.com)(PORT=1522)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=devorc02)));User Id=hr;Password=hr;";

            OracleConnection con = new OracleConnection();
            con.ConnectionString = cs;
            con.Open();

            OracleCommand cmd = con.CreateCommand();
            cmd.CommandText = "HR_DEPTPERCOUNTRY";
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            OracleParameter orcParam = new OracleParameter("CNTR_CD", OracleDbType.Varchar2);
            orcParam.Size = 50;
            orcParam.Value = "UK";
            orcParam.Direction = System.Data.ParameterDirection.Input;
            cmd.Parameters.Add(orcParam);

            OracleParameter orcOutParam = new OracleParameter("RS_CURSOR", OracleDbType.RefCursor);
            orcOutParam.Size = 50;
            orcOutParam.Direction = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add(orcOutParam);

            cmd.ExecuteNonQuery();

            OracleDataReader reader = ((OracleRefCursor)cmd.Parameters["RS_CURSOR"].Value).GetDataReader();

            while (reader.Read())
            {
                Console.WriteLine("Dept Name: {0} | Address: {1}, | Country: {2}", reader.GetString(0), reader.GetString(1), reader.GetString(2));
            }
        }
开发者ID:devworker55,项目名称:SourceLab,代码行数:32,代码来源:Program.cs

示例3: CallFuncWithTable

        /// <summary>
        /// 测试 调用 Oracle 返回结果集的函数.
        /// </summary>
        private void CallFuncWithTable(OracleConnection conn)
        {
            // 创建一个 Command.
            OracleCommand testCommand = conn.CreateCommand();

            // 定义需要执行的SQL语句.
            testCommand.CommandText = "pkg_HelloWorld.getHelloWorld";

            // 定义好,本次执行的类型,是存储过程.
            testCommand.CommandType = CommandType.StoredProcedure;

            // 定义好,我这个参数,是 游标 + 返回值.
            OracleParameter para = new OracleParameter("c", OracleDbType.RefCursor);
            para.Direction = ParameterDirection.ReturnValue;
            testCommand.Parameters.Add(para);


            // 执行SQL命令,结果存储到Reader中.
            OracleDataReader testReader = testCommand.ExecuteReader();

            // 处理检索出来的每一条数据.
            while (testReader.Read())
            {
                // 将检索出来的数据,输出到屏幕上.
                Console.WriteLine("调用函数:{0}; 返回:{1} - {2}",
                    testCommand.CommandText, testReader[0], testReader[1]
                    );
            }

            // 关闭Reader.
            testReader.Close();
        }
开发者ID:mahuidong,项目名称:my-csharp-sample,代码行数:35,代码来源:CallOracleFuncProc.cs

示例4: IsExistsEmail

 public ChangeResultSettings IsExistsEmail(string email)
 {
     var result = new ChangeResultSettings();
     try
     {
         ConnectDB.CloseConnection(_connectGs);
         _connectGs = new OracleConnection();
         _connectGs = ConnectDB.GetOracleConnection(_connectGs);
         var cm = _connectGs.CreateCommand();
         cm.CommandText = "usp_check_exists_email";
         cm.CommandType = CommandType.StoredProcedure;
         cm.Parameters.Add(new OracleParameter("email_check", OracleDbType.Varchar2)).Value = email;
         var op = new OracleParameter("total_result", OracleDbType.Long, 15) { Direction = ParameterDirection.Output };
         cm.Parameters.Add(op);
         cm.ExecuteNonQuery();
         var total = Convert.ToInt32(cm.Parameters["total_result"].Value.ToString());
         switch (total)
         {
             case 0:
                 result.ChangeResult = ChangeResult.ThanhCong;
                 break;
             default:
                 result.ChangeResult = ChangeResult.ThatBai;
                 break;
         }
     }
     catch (Exception ex)
     {
         result.Message = "Có lỗi trong quá trình kiểm tra email. Vui lòng thử lại!";
         result.ChangeResult = ChangeResult.ThatBai;
     }
     return result;
 }
开发者ID:nstungxd,项目名称:ips-project-vdc,代码行数:33,代码来源:UserRepository.cs

示例5: ChiTietDuAn

        public DataTable ChiTietDuAn(string mdv, string nsd, string pas, string maDonVi, long idDuAn)
        {
            try
            {
                ConnectDB.CloseConnection(_connectGs);
                _connectGs = new OracleConnection();
                _connectGs = ConnectDB.GetOracleConnection(_connectGs);
                var cm = _connectGs.CreateCommand();
                cm.CommandText = "usp_ChiTiet_DuAn";
                cm.CommandType = CommandType.StoredProcedure;
                cm.Parameters.Add(new OracleParameter("ma_donvi", OracleDbType.Varchar2)).Value = "";
                cm.Parameters.Add(new OracleParameter("nsd", OracleDbType.Varchar2)).Value = "";
                cm.Parameters.Add(new OracleParameter("pas", OracleDbType.Varchar2)).Value = "";
                cm.Parameters.Add(new OracleParameter("id_duan", OracleDbType.Long)).Value = idDuAn;
                cm.Parameters.Add(new OracleParameter("ma_donvi_thuchien", OracleDbType.Varchar2)).Value = maDonVi;
                cm.Parameters.Add(new OracleParameter("cs_lke", OracleDbType.RefCursor)).Direction =
                    ParameterDirection.Output;

                var tableGs = new DataTable();
                _oracleAdapter = new OracleDataAdapter(cm);
                _oracleAdapter.Fill(tableGs);
                return tableGs;
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                ConnectDB.CloseConnection(_connectGs);
            }
        }
开发者ID:nstungxd,项目名称:ips-project-vdc,代码行数:32,代码来源:GiamSatRepository.cs

示例6: CapNhatLoaiNguonVon

 public ChangeResultSettings CapNhatLoaiNguonVon(string mdv, string nsd, string pas, string maDonVi, long idDuAn, int loaiNguonVon)
 {
     var result = new ChangeResultSettings();
     try
     {
         ConnectDB.CloseConnection(_connectGs);
         _connectGs = new OracleConnection();
         _connectGs = ConnectDB.GetOracleConnection(_connectGs);
         var cm = _connectGs.CreateCommand();
         cm.CommandText = "usp_CapNhat_DuAn_LoaiNguonVon";
         cm.CommandType = CommandType.StoredProcedure;
         cm.Parameters.Add(new OracleParameter("ma_donvi", OracleDbType.Varchar2)).Value = "";
         cm.Parameters.Add(new OracleParameter("nsd", OracleDbType.Varchar2)).Value = "";
         cm.Parameters.Add(new OracleParameter("pas", OracleDbType.Varchar2)).Value = "";
         cm.Parameters.Add(new OracleParameter("id_duan", OracleDbType.Long)).Value = idDuAn;
         cm.Parameters.Add(new OracleParameter("ma_donvi_thuchien", OracleDbType.Varchar2)).Value = maDonVi;
         cm.Parameters.Add(new OracleParameter("loai_nguonvon", OracleDbType.Int32)).Value = loaiNguonVon;
         var op = new OracleParameter("row_updated", OracleDbType.Long, 15) { Direction = ParameterDirection.Output };
         cm.Parameters.Add(op);
         cm.ExecuteNonQuery();
         var rowUpdated = cm.Parameters["row_updated"].Value.ToString();
         if (rowUpdated == "0")
             result.ChangeResult = ChangeResult.ThatBai;
     }
     catch (Exception ex)
     {
         result.ChangeResult = ChangeResult.ThatBai;
         result.Message = ex.Message;
         throw;
     }
     return result;
 }
开发者ID:nstungxd,项目名称:ips-project-vdc,代码行数:32,代码来源:GiamSatRepository.cs

示例7: ODPNetConnect

        /// <summary>
        /// Construtor, por default já conecta no banco de dados, caso não queira passe false no parâmetro.
        /// Construct open database connetion by default, if you don't want set startConnection = false
        /// </summary>
        /// <param name="startConnection">
        ///     Conectar no banco de dados, default true
        ///     Open database connection
        /// </param>
        public ODPNetConnect(bool startConnection = false)
        {
            ClearMessages();
            if (!startConnection)
            {
                return;
            }

            myConnection = GetConnection();
            if (!String.IsNullOrWhiteSpace(this.ERROR)) //Erro ao conectar. Connection error
            {
                return;
            }

            try
            {
                if (!myConnection.State.ToString().Equals("Open"))
                {
                    myConnection.Open();
                }

                myCommand = myConnection.CreateCommand();
            }
            catch (Exception e)
            {
                ERROR = e.Message;
                if (e.InnerException != null)
                {
                    ERROR += e.InnerException.Message;
                }
            }
        }
开发者ID:pedro-muniz,项目名称:ODPNetConnect,代码行数:40,代码来源:ODPNetConnect.cs

示例8: ExecuteQuery

        /// <summary>
        /// выполнение запроса к базе
        /// </summary>
        /// <param name="cmdString">строка запроса</param>
        /// <returns>возвращает значение bool выполнено или нет</returns>
        public static bool ExecuteQuery(string cmdString)
        {
            using (var connection = new OracleConnection(GetConnectionString()))
            {
                var cmd = connection.CreateCommand();
                cmd.CommandText = cmdString;
                try
                {
                    connection.Open();
                    var transaction = connection.BeginTransaction();
                    Debug.WriteLine("Соединение открыто");
                    cmd.ExecuteNonQuery();
                    transaction.Commit();
                    Debug.WriteLine("Запрос выполнен");

                }
                catch (OracleException exception)
                {
                    Debug.WriteLine(exception.Message);
                    return false;
                }
                finally
                {
                    connection.Close();
                    Debug.WriteLine("Соединение закрыто");
                }
            }
            return true;
        }
开发者ID:silan4ik,项目名称:UploadLASFiles,代码行数:34,代码来源:Tools.cs

示例9: DatabaseKoppeling

 public DatabaseKoppeling()
 {
     string user = "TURVEN";
     string pw = "FRAGIE";
     conn = new OracleConnection();
     command = conn.CreateCommand();
     conn.ConnectionString = "User Id=" + user + ";Password=" + pw + ";Data Source=" + " //localhost:1521/xe" + ";";
 }
开发者ID:mrhaver,项目名称:TurfProject,代码行数:8,代码来源:DatabaseKoppeling.cs

示例10: Start

        public void Start()
        {
            string connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.3.92)(PORT=1521))(CONNECT_DATA=(SID=XE)));User Id=sa;Password=sa123456;";
            OracleConnection conn = new OracleConnection(connectionString);
            conn.Open();

            OracleCommand cmd = conn.CreateCommand();
            cmd.CommandText = "select * from test";
            IDataReader dr = cmd.ExecuteReader();
        }
开发者ID:hhahh2011,项目名称:CH.Study,代码行数:10,代码来源:OracleTest.cs

示例11: DBReader

 public DBReader(String ConnStr_, String PipeName_)
 {
     using (Logger l = new Logger("PipeCatcher"))
     {
         ConnStr = ConnStr_;
         PipeName = PipeName_;
         OraConn = new OracleConnection(ConnStr);
         OraCmd = OraConn.CreateCommand();
         l.msg("A new DBReader created ConnStr={0} PipeName={1}", ConnStr, PipeName);
     }
 }
开发者ID:pulse-computer-consulting,项目名称:NucleusPub,代码行数:11,代码来源:DBReader.cs

示例12: CreateQueueIfNecessary

 public static void CreateQueueIfNecessary(Address address, string connectionString)
 {
     using (OracleConnection connection = new OracleConnection(connectionString))
     {
         OracleCommand cmd = connection.CreateCommand();
         cmd.CommandText = InstallSql;
         cmd.Parameters.Add("queue", NormalizeQueueName(address));
         cmd.Parameters.Add("queueTable", (NormalizeQueueName(address) + "_tab").ToUpper());
         connection.Open();
         cmd.ExecuteNonQuery();
     }
 }
开发者ID:rosieks,项目名称:NServiceBus-Contrib,代码行数:12,代码来源:OracleAqsUtilities.cs

示例13: GetMessages

        public static List<MessageInfo> GetMessages(string businessId, DBConnection connection)
        {
            var connString = connection.getConnectionString();

               var result = new List<MessageInfo>();

               var output = "npu, correlationNpu, businessid, creationdate, processid, interfacetoinvoke, operation, payload";
               var filter = string.Format(" businessId = '{0}' ", businessId) ;
               var orderBy = " ORDER BY creationdate ASC";

               if (!string.IsNullOrEmpty(Configuration.IgnoreOperations))
               {
               var opers = Configuration.IgnoreOperations.Split(';');

               var formOper = " {0} AND NPU not like '%{1}%' ";

               foreach (var o in opers)
               {
                   filter = string.Format(formOper, filter, o);
               }
               }

               using(OracleConnection conn = new OracleConnection(connString)){

               var command = conn.CreateCommand();

               command.CommandText = connection.CreateQuery(output, "pt_msg_inbound", filter, orderBy);
               conn.Open();

               var reader = command.ExecuteReader();

               while (reader.Read())
               {
                   var msg = MessageInfo.LoadFromDB(reader);
                   result.Add(msg);
               }

               command.CommandText = connection.CreateQuery(output, "pt_msg_inbound_archive", filter, orderBy);
               reader = command.ExecuteReader();

               while (reader.Read())
               {
                   var msg = MessageInfo.LoadFromDB(reader);
                   result.Add(msg);

               }

               }

               result = result.OrderBy(a => a.ReceivedDatetime).ToList();

               return result;
        }
开发者ID:jmacnico,项目名称:Proxmulator,代码行数:53,代码来源:DBAccess.cs

示例14: Init

        /// <summary>
        /// Initializes the message receiver.
        /// </summary>
        /// <param name="address">The address of the message source.</param>
        /// <param name="transactional">Indicates if the receiver should be transactional.</param>
        public void Init(Address address, bool transactional)
        {
            this.inputQueueAddress = OracleAqsUtilities.NormalizeQueueName(address);

            using (OracleConnection conn = new OracleConnection(this.ConnectionString))
            {
                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT queue_table FROM dba_queues WHERE name = :queue";
                cmd.Parameters.Add("queue", this.inputQueueAddress);
                conn.Open();
                this.queueTable = cmd.ExecuteScalar() as string;
            }
        }
开发者ID:rosieks,项目名称:NServiceBus-Contrib,代码行数:18,代码来源:OracleAqsMessageReceiver.cs

示例15: getResultTable

        public static DataSet getResultTable(OracleConnection conn, string sqlText)
        {
            OracleCommand cmd = conn.CreateCommand();

            cmd.CommandText = sqlText;

            OracleDataAdapter adapter = new OracleDataAdapter(cmd);
            DataSet ds = new DataSet();
            ds.Tables.Add(new DataTable("DbSource"));
            adapter.Fill(ds, "DbSource");

            return ds;
        }
开发者ID:xusheng666,项目名称:DB_Scheme_Extract,代码行数:13,代码来源:OracleClient.cs


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