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


C# Client.OracleConnection类代码示例

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


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

示例1: CreateDbConnection

 /// <summary>
 /// 根据配置文件中所配置的数据库类型和传入的
 /// 数据库链接字符串来创建相应数据库连接对象
 /// </summary>
 /// <param name="connectionString"></param>
 /// <returns></returns>
 public static DbConnection CreateDbConnection(string connectionString)
 {
     DbConnection conn = null;
     switch (DbHelper.DbType)
     {
         case DatabaseType.SqlServer:
             conn = new SqlConnection(connectionString);
             break;
         case DatabaseType.Oracle:
             conn = new OracleConnection(connectionString);
             break;
         case DatabaseType.MySql:
             conn = new MySqlConnection(connectionString);
             break;
         case DatabaseType.Access:
             conn = new OleDbConnection(connectionString);
             break;
         case DatabaseType.SQLite:
             conn = new SQLiteConnection(connectionString);
             break;
         default:
             throw new Exception("数据库类型目前不支持!");
     }
     return conn;
 }
开发者ID:zhujinfei5151,项目名称:CSoft.CMS,代码行数:31,代码来源:DbFactory.cs

示例2: 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

示例3: ReadDataToDataSet

        /// <summary>
        /// 将数据读取到 DataSet 中.
        /// </summary>
        public void ReadDataToDataSet()
        {

            Console.WriteLine("使用DataAdapter,将数据填充到DataSet中,然后脱离数据库,直接对DataSet进行处理。");

            // 建立数据库连接.
            OracleConnection conn = new OracleConnection(connString);

            // 创建一个适配器
            OracleDataAdapter adapter = new OracleDataAdapter(SQL, conn);

            // 创建DataSet,用于存储数据.
            DataSet testDataSet = new DataSet();

            // 执行查询,并将数据导入DataSet.
            adapter.Fill(testDataSet, "result_data");

            // 关闭数据库连接.
            conn.Close();

            // 处理DataSet中的每一行数据.
            foreach (DataRow testRow in testDataSet.Tables["result_data"].Rows)
            {
                // 将检索出来的数据,输出到屏幕上.
                Console.WriteLine("NO:{0} ;  Date:{1} ; Money:{2}   ",
                    testRow["NO"], testRow["SALE_DATE"], testRow["SUM_MONEY"]
                    );
            }
        }
开发者ID:mahuidong,项目名称:my-csharp-sample,代码行数:32,代码来源:ReadOracleData.cs

示例4: 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

示例5: Connect

 public void Connect()
 {
     con = new OracleConnection();
     con.ConnectionString = connectionstring;
     con.Open();
     Console.WriteLine("Connection succesfull");
 }
开发者ID:dunchel,项目名称:Pathe,代码行数:7,代码来源:DatabaseHandler.cs

示例6: Connection

        private Connection()
        {
            try
            {
                string Dsource = "(DESCRIPTION="
               + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)"
               + "(HOST=bd.thronewars.ca)(PORT=1521)))"
               + "(CONNECT_DATA=(SERVICE_NAME=ORCL)))";

                String ChaineConnexion = "Data Source=" + Dsource
                + ";User Id=THRONE; Password =Warst";
                conn = new OracleConnection(ChaineConnexion);

                conn.Open();

                if (conn.State.ToString() != "Open")
                {
                    // to do
                }

            }
            catch (OracleException ex)
            {
                Erreur.ErrorMessage(ex);
            }
        }
开发者ID:daren511,项目名称:ThroneWarsServer,代码行数:26,代码来源:Connection.cs

示例7: Limpeza

        public bool Limpeza()
        {
            bool ret = false;
            try
            {
                using (OracleConnection connection = new OracleConnection(RetornoCIP.CNX_C3))
                {
                    OracleCommand command = new OracleCommand("TRUNCATE TABLE CCCTBLBRE", connection);
                    command.CommandType = CommandType.Text;

                    connection.Open();
                    command.ExecuteNonQuery();
                    connection.Close();

                    if (Utils._logger != null)
                        Utils._logger.Info("Limpeza ok");

                    ret = true;
                }
            }
            catch (Exception ex)
            {
                if (Utils._logger != null)
                    Utils._logger.Error(ex.Message);
            }
            return ret;
        }
开发者ID:GregXP,项目名称:XP,代码行数:27,代码来源:DAL.cs

示例8: HaalGebruikersOp

 /// <summary>
 /// Use only to retrieve user on initialization
 /// </summary>
 /// <param name="query">The input query</param>
 /// <returns>A DataTable containing the results of the query</returns>
 public static DataTable HaalGebruikersOp(string query)
 {
     using (OracleConnection conn = new OracleConnection(connectionstring2))
     {
         try
         {
             conn.Open();
             OracleCommand cmd = new OracleCommand(query);
             cmd.Connection = conn;
             try
             {
                 OracleDataReader reader = cmd.ExecuteReader();
                 DataTable result = new DataTable();
                 result.Load(reader);
                 conn.Close();
                 return result;
             }
             catch (OracleException ex)
             {
                 Console.WriteLine(ex.Message);
                 throw;
             }
         }
         catch (OracleException ex)
         {
             Console.WriteLine(ex.Message);
             return new DataTable();
         }
     }
 }
开发者ID:kndschilders,项目名称:Profchat,代码行数:35,代码来源:Database.cs

示例9: AddIncident

        public static bool AddIncident(Incident i, int missieUID)
        {
            using (OracleConnection o = new OracleConnection(connstring))
            {
                using (OracleCommand c = new OracleCommand())
                {
                    try
                    {
                        c.Connection = o;
                        o.Open();
                        c.CommandText = "INSERT INTO TIncident (Beschrijving) VALUES ('" + i.Beschrijving + "')";
                        c.ExecuteNonQuery();

                        c.CommandText = "SELECT MAX(ID) FROM TIncident";
                        OracleDataReader dr = c.ExecuteReader();

                        if (dr.Read())
                        {
                            c.CommandText = "INSERT INTO TMissie_Incident (MissieID, IncidentID) VALUES ('" + missieUID + "', '" + GetInt(dr[0]) + "')";
                            c.ExecuteNonQuery();
                        }
                        return true;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                        return false;
                    }
                    finally
                    {
                        o.Close();
                    }
                }
            }
        }
开发者ID:Stannnnn,项目名称:Live_Performance,代码行数:35,代码来源:DBConnect.cs

示例10: GetBusinessObject

        public IBeheerContextEntity GetBusinessObject(string qry, BeheerContextEntity beheerObject)            
        {
            using (var conn = new OracleConnection(_oradb))
            {
                conn.Open();                
                var cmd = new OracleCommand
                {
                    Connection = conn,
                    CommandText = qry,
                    CommandType = CommandType.Text
                };
                cmd.Connection = conn;
                var reader = cmd.ExecuteReader();

                var smartReader = new SmartDataReader(reader);

                BeheerContextEntity businessObject = null;
                while (smartReader.Read())
                {
                    businessObject = new BeheerContextEntity
                    {
                        Id = smartReader.GetInt32("id"),
                        DataKeyValue = smartReader.GetString(beheerObject.DataKeyName, ""),
                        Tablename = beheerObject.Tablename,
                        DataKeyName = beheerObject.DataKeyName
                    };
                }
                return businessObject;
            }
        }
开发者ID:Letractively,项目名称:henoch,代码行数:30,代码来源:OracleAccess.cs

示例11: OpenDb

        public virtual IDb OpenDb()
		{
            IDbConnection cn = new Oracle.DataAccess.Client.OracleConnection(connString);
			//cn.Open();
            IDb db = new OrlDb(this, cn);
			return db;
		}
开发者ID:priceLiu,项目名称:Enterprise.Company,代码行数:7,代码来源:OrlProvider.cs

示例12: 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

示例13: OracleTransformationProvider

 public OracleTransformationProvider(Dialect dialect, string connectionString)
     : base(dialect, connectionString)
 {
     _connection = new OracleConnection();
     _connection.ConnectionString = _connectionString;
     _connection.Open();
 }
开发者ID:asynchrony,项目名称:Migrator.NET,代码行数:7,代码来源:OracleTransformationProvider.cs

示例14: DataTable

        public DataTable Consulta
        (
            string pQuery,
            string pConnectionString
        )
        {
            DataTable lTable = new DataTable();
            DataSet lDataSet = new DataSet();
            OracleConnection lConnection = new OracleConnection(pConnectionString);

            try
            {
                lConnection.Open();

                OracleDataAdapter lDataAdapter = new OracleDataAdapter(pQuery, pConnectionString);

                lDataAdapter.Fill(lDataSet);

                lTable = lDataSet.Tables[0];

                return lTable;
            }
            finally
            {
                lConnection.Close();
            }
        }
开发者ID:andreibaptista,项目名称:DEF_PUB_PORTAL,代码行数:27,代码来源:OracleDo.cs

示例15: ConnectionData

        public static OracleConnection ConnectionData()
        {
            string cnStr = "Data Source=(DESPRIPTION =(ADDPRESS_LIST =(ADDPRESS = (PROTOCOL = TCP)(HOST= localhost)(PORT= = 1521)))(CONNECT_DATA =(SERVICE_NAME = ORCL))); User Id = QUANLY; Password=123456";

            cn = new OracleConnection(cnStr);
            return cn;
        }
开发者ID:nguyenbathong123,项目名称:baitaplonbaomat,代码行数:7,代码来源:Connection.cs


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