當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。