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


C# OracleConnection.Dispose方法代码示例

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


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

示例1: createPost

        public void createPost(Member member)
        {
            try
            {

                String connstr = "Data source = studentoracle.students.ittralee.ie/orcl;User id = t00171832;Password=" + getPassword() + ";";
                OracleConnection conn = new OracleConnection(connstr);
                conn.Open();

                string query = "insert into posts values('" + member.Username + "', '" + member.Email + "' , " + member.Phone + " , :BlobParameter , '" + member.Image + "' , '"
                    + member.JoinDate + "' , " + member.MsgPrivate + " , '" + member.LastSeen  + ")";
                MessageBox.Show(query);
                //insert the byte as oracle parameter of type blob
                OracleParameter blobParameter = new OracleParameter();
                blobParameter.OracleType = OracleType.Blob;
                blobParameter.ParameterName = "BlobParameter";
                blobParameter.Value = member.Image;

                OracleCommand cmnd = new OracleCommand(query, conn);
                cmnd.Parameters.Add(blobParameter);
                cmnd.ExecuteNonQuery();
                cmnd.Dispose();
                conn.Close();
                conn.Dispose();
            }
            catch (Exception ex)
            {
            }
        }
开发者ID:LukeBluett,项目名称:PostBored,代码行数:29,代码来源:MemberDAOImpl.cs

示例2: TestConnect

        public static bool TestConnect(string user, string pwd, string serviceName, out string msg)
        {
            //Data Source=lan_189;User ID=user_ahdy_shi;Password=user_ahdy_shi
            string conn = string.Format("Data Source={0};User ID={1};Password={2}", serviceName.Trim(), user, pwd);

            try
            {
                using (OracleConnection con = new OracleConnection(conn))
                {
                    OracleConnection.ClearPool(con);
                    System.Threading.Thread.Sleep(100);
                    con.Open();

                    con.Close();
                    con.Dispose();
                }

                msg = "连接" + serviceName.ToUpper() + "成功";
                return true;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return false;
            }
        }
开发者ID:howbigbobo,项目名称:DailyCode,代码行数:26,代码来源:OraTestConnect.cs

示例3: make_connection

        public List<String> make_connection()
        {
            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
            string selectStmt = string.Format("select car.*, mar.IMENAMARKA from VOZILA car, MODELI mod, MARKA mar where car.IMENAMODEL = mod.IMENAMODEL and mod.IMENAMARKA = mar.IMENAMARKA ");

            OracleCommand cmd = new OracleCommand(selectStmt, conn);
            OracleDataReader dataReader = cmd.ExecuteReader();

            List<String> redovi = new List<string>();
            while (dataReader.Read())
            {
                string temp = dataReader.GetString(1).ToString() + " ";
                temp = temp + dataReader.GetString(16).ToString() + " ";
                temp = temp + dataReader.GetString(15).ToString() + " ";
                temp = temp + dataReader.GetValue(2).ToString() + " ";
                temp = temp + dataReader.GetValue(3).ToString() + " ";
                temp = temp + dataReader.GetValue(4).ToString() + " ";
                temp = temp + dataReader.GetValue(5).ToString() + " ";
                temp = temp + dataReader.GetValue(6).ToString() + " ";
                temp = temp + dataReader.GetValue(7).ToString() ;

                redovi.Add(temp);
            }

            conn.Close();
            conn.Dispose();

            return redovi;
        }
开发者ID:HristijanTodorovski,项目名称:AutoCompany,代码行数:30,代码来源:GetCarInfo.cs

示例4: Close

 /// <summary>
 ///  关闭数据库
 /// </summary>
 /// <param name="connection">OracleConnection连接对象</param>
 public static void Close(OracleConnection connection)
 {
     if (connection != null)
     {
         try
         {
             if (connection.State == ConnectionState.Open)
             {
                 connection.Close();
                 connection.Dispose();
             }
         }
         catch (System.Exception ex)
         {
             connection.Close();
             connection.Dispose();
             Tracer.Debug("关闭数据库出错:" + ex.ToString());
         }
     }
 }
开发者ID:SaintLoong,项目名称:TMFlow,代码行数:24,代码来源:MsOracle.cs

示例5: Close

 /// <summary>
 ///  关闭数据库
 /// </summary>
 /// <param name="connection">OracleConnection连接对象</param>
 public static void Close(OracleConnection connection)
 {
     if (connection != null)
     {
         try
         {
             if (connection.State == ConnectionState.Open)
             {
                 connection.Close();
                 connection.Dispose();
             }
         }
         catch (System.Exception ex)
         {
             connection.Close();
             connection.Dispose();
             throw new System.Exception(ex.Message);
         }
     }
 }
开发者ID:SaintLoong,项目名称:TMFlow,代码行数:24,代码来源:OracleDataProvider.cs

示例6: Check

        /// <summary>
        /// Detects if connection to database can be established based on username,
        /// password and database name.
        /// </summary>
        /// <param name="p_datasource">Connection string in the .net form off: "User Id="+username+";Password="+password+";Data Source="+database;</param>
        public static void Check(string p_datasource)
        {
            OracleConnection con = new OracleConnection();

            //using connection string attributes to connect to Oracle Database
            con.ConnectionString = p_datasource;
            try
            {
                con.Open();
                Console.WriteLine("Connection succesfull");
                Console.WriteLine("Server version: {0}", con.ServerVersion);
            }
            catch (OracleException e)
            {
                Console.WriteLine("Connection failed");
                Console.WriteLine(e.Message);
                Environment.Exit(1);
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
        }
开发者ID:chadclan,项目名称:sqlmake,代码行数:29,代码来源:CheckConnection.cs

示例7: ExecuteSQL

 /// <summary>
 /// 执行一个SQL语句命令,没有返回数据集,只返回影响记录数
 /// </summary>
 /// <param name="conn">OracleConnection</param>
 /// <param name="sqlString">SQL语句</param>
 /// <param name="param">参数数组</param>
 /// <returns></returns>
 public static int ExecuteSQL(OracleConnection conn,string sqlString, params OracleParameter[] param)
 {
     if (conn.State==ConnectionState.Closed)
     {
         conn.Open();                
     }
     int n= ExecuteNonQuery(conn, CommandType.Text, sqlString, param);
     conn.Close();
     conn.Dispose();
     return n;
 }
开发者ID:JuRogn,项目名称:OA,代码行数:18,代码来源:MsOracle.cs

示例8: ExecuteDataset

        /// <summary>
        /// 执行一个OracleCommand命令并返回结果集

        /// </summary>
        /// <remarks>
        /// 例如:  
        ///  DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new OracleParameter("@prodid", 24));
        /// </remarks>
        /// <param name="connection">有效的 OracleConnection</param>
        /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
        /// <param name="commandText">存储过程名称或 PL/SQL</param> 
        /// <param name="commandParameters">params OracleParameter[]</param>
        /// <returns>返回DataSet</returns>
        public static DataSet ExecuteDataset(OracleConnection connection, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
        {
            try
            {
                OracleCommand cmd = new OracleCommand();
                PrepareCommand(cmd, connection, (OracleTransaction)null, commandType, commandText, commandParameters);

                OracleDataAdapter da = new OracleDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                return ds;
            }
            catch (System.Exception ex)
            {
                connection.Close();
                connection.Dispose();
                LogHelper.WriteLog("ExecuteDataset出错:" + ex.ToString());
                return null;
            }
        }
开发者ID:JuRogn,项目名称:OA,代码行数:33,代码来源:MsOracle.cs

示例9: Open

 /// <summary>
 ///  打开数据库
 /// </summary>
 /// <param name="connection">OracleConnection连接对象</param>
 public static void Open(OracleConnection connection)
 {
     if (connection != null)
     {
         try
         {
             if (connection.State != ConnectionState.Open)
             {
                 connection.Open();
             }
         }
         catch (System.Exception ex)
         {
             connection.Close();
             connection.Dispose();
             LogHelper.WriteLog("打开数据库出错:" + ex.ToString());
         }
     }
 }
开发者ID:JuRogn,项目名称:OA,代码行数:23,代码来源:MsOracle.cs

示例10: GV_RowUpdating

        protected void GV_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            using (OracleConnection conn = new OracleConnection(DBHelper.ConnectionString))
            {
                string reason_id = GV.DataKeys[e.RowIndex].Values[0].ToString();
                string reason_desc = ((TextBox)GV.Rows[e.RowIndex].FindControl("TxtDesc")).Text;
                string active = ((CheckBox)(GV.Rows[e.RowIndex].FindControl("ChkActive"))).Checked == true ? "1" : "0";
                string sqlupdate = "update jp_lack_reason set reason_desc = '" + reason_desc + "',is_valid='" + active + "' where reason_id = '" + reason_id + "' ";
                OracleCommand updatecomm = new OracleCommand(sqlupdate, conn);
                try
                {
                    conn.Open();
                    updatecomm.ExecuteNonQuery();

                    GV.EditIndex = -1;
                    GVDataBind();

                }
                catch (Exception ex)
                {
                    conn.Close();
                    Response.Write("<script language=javascript>alert('" + ex.Message + "')</script>");
                }
                finally
                {
                    updatecomm.Dispose();
                    conn.Dispose();
                    conn.Close();
                }
            }
        }
开发者ID:freudshow,项目名称:raffles-codes,代码行数:31,代码来源:lack_reason.aspx.cs

示例11: ExecuteScalar

 /// <summary>
 /// 返回结果集的第一行第一列; 执行完成没有关闭OracleConnection连接,需要手动关闭
 /// </summary>
 /// <remarks>
 /// 例如:  
 ///  int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount", new OracleParameter("@prodid", 24));
 /// </remarks>
 /// <param name="connection">有效的 OracleConnection</param>
 /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
 /// <param name="commandText">存储过程T-OleDb的名称或命令</param>
 /// <param name="commandParameters">params OracleParameter[]</param>
 /// <returns>返回结果集的第一行第一列</returns>
 public static object ExecuteScalar(OracleConnection connection, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
 {
     try
     {
         OracleCommand cmd = new OracleCommand();
         PrepareCommand(cmd, connection, (OracleTransaction)null, commandType, commandText, commandParameters);
         return cmd.ExecuteScalar();
     }
     catch (System.Exception e)
     {
         if (connection.State == ConnectionState.Open)
         {
             connection.Close();
             connection.Dispose();
         }
         throw new System.Exception(e.Message, e);
     }
 }
开发者ID:JuRogn,项目名称:OA,代码行数:30,代码来源:OracleDataProvider.cs

示例12: CallProce

 private void CallProce(string RECORD_ID, string ICCARD_TRANS_FLAG, string NAME_TRANS_FLAG, string ERR_MSG)
 {
     OracleConnection conn = new OracleConnection(OracleHelper.OraConnectString);
     OracleCommand comm = new OracleCommand();
     comm.Connection = conn;
     if (conn.State == ConnectionState.Closed) conn.Open();
     comm.CommandType = CommandType.StoredProcedure;
     comm.CommandText = "UPDATE_CIMC_LBR_IDCARD_TRANS";
     OracleTransaction oTran = conn.BeginTransaction();
     comm.Transaction = oTran;
     try
     {
         comm.Parameters.Add("RECORD_ID_", OracleType.Int32).Value = Convert.ToInt32(RECORD_ID);
         comm.Parameters.Add("ICCARD_TRANS_FLAG_", OracleType.VarChar, 1).Value = ICCARD_TRANS_FLAG;
         comm.Parameters.Add("NAME_TRANS_FLAG_", OracleType.VarChar, 1).Value = NAME_TRANS_FLAG;
         comm.Parameters.Add("ERR_MSG_", OracleType.VarChar, 3000).Value = ERR_MSG;
         comm.ExecuteNonQuery();
         oTran.Commit();
     }
     catch (Exception ex)
     {
         oTran.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         conn.Close();
         conn.Dispose();
         comm.Dispose();
     }
 }
开发者ID:freudshow,项目名称:raffles-codes,代码行数:31,代码来源:PhotoManager.cs

示例13: TestPersistSucurityInfo6

		public static void TestPersistSucurityInfo6() 
		{
			Console.WriteLine("\nTestPersistSucurityInfo6 - external auth using persist security info");

			string user = Environment.UserName;
			if (!Environment.UserDomainName.Equals(String.Empty))
				user = Environment.UserDomainName + "\\" + Environment.UserName;
			Console.WriteLine("Environment UserDomainName and UserName: " + user);
			Console.WriteLine("Open connection using external authentication...");
			OracleConnection con = new OracleConnection("Data Source=palis;Integrated Security=true");
			Console.WriteLine("ConnectionString before open: " + con.ConnectionString);
			try {
				con.Open();
				OracleCommand cmd = con.CreateCommand();
				cmd.CommandText = "SELECT USER FROM DUAL";
				OracleDataReader reader = cmd.ExecuteReader();
				if (reader.Read())
					Console.WriteLine("User: " + reader.GetString(reader.GetOrdinal("USER")));
				con.Close();
				Console.WriteLine("ConnectionString after close: " + con.ConnectionString);
			}
			catch (Exception e) {
				Console.WriteLine("Exception caught: " + e.Message);
				Console.WriteLine("Probably not setup for external authentication. This is fine.");
			}
			con.Dispose();
			Console.WriteLine("ConnectionString after dispose: " + con.ConnectionString);
			con = null;
			Console.WriteLine("\n\n");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:30,代码来源:TestOracleClient.cs

示例14: CheckDPISConnect

        public static string CheckDPISConnect()
        {
            string ret = "false";
            string connStr = DPISConnectionString;
            OracleConnection conn = new OracleConnection(connStr);
            try
            {
                conn.Open();

                string ServerName = conn.DataSource;
                string DbName = conn.Database;

                ret = "true|ServerName = " + ServerName + "&DatabaseName=" + DbName;
            }
            catch (Exception ex)
            {
                ret = "false|Exception " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine;
                ret += "ConnectionString = " + connStr;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

            return ret;
        }
开发者ID:TIT-tech,项目名称:OPM_BO,代码行数:27,代码来源:SharedDB.cs

示例15: GetDataTable

        /// <summary>
        /// 执行SQL语句,返回DataTable;执行完成自动关闭OracleConnection连接
        /// </summary>
        /// <param name="connection">有效的 OracleConnection</param>
        /// <param name="cmd">OracleCommand对象</param>
        /// <param name="sql">SQL语句</param>
        /// <returns></returns>
        public static DataTable GetDataTable(OracleConnection connection, OracleCommand cmd, string sql)
        {
            try
            {

                PrepareCommand(cmd, connection, (OracleTransaction)null, CommandType.Text, sql, (OracleParameter[])null);

                OracleDataAdapter da = new OracleDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                connection.Close();
                connection.Dispose();
                return ds.Tables[0];
            }
            catch (System.Exception e)
            {
                connection.Close();
                connection.Dispose();
                throw new System.Exception(e.Message, e);
            }
        }
开发者ID:JuRogn,项目名称:OA,代码行数:28,代码来源:OracleDataProvider.cs


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