コード例 #1
0
        public override DBDataCollection ExcuteProcedure(string sp_name, bool isReturnDataSet, ref DBOParameterCollection dbp)
        {
            DBDataCollection rtn = new DBDataCollection();

            rtn.IsSuccess = false;

            DataSetStd   ds = new DataSetStd();
            MySqlCommand dc = null;//new SqlCommand(p.StoreProcureName, this.sqlconn);

            if (this._s == DBStatus.Begin_Trans)
            {
                dc = new MySqlCommand(sp_name, this.conn, this.tran);
            }
            else
            {
                dc = new MySqlCommand(sp_name, this.conn);
            }
            dc.CommandTimeout = CommandTimeOut;
            dc.CommandType    = CommandType.StoredProcedure;
            FillParametersToCommand(dc, dbp);
            MySqlDataReader ddr = null;

            try
            {
                if (isReturnDataSet)
                {
                    ddr = dc.ExecuteReader();
                    ds  = DataSetStd.FillData(ddr);
                    rtn.ReturnDataSet = ds;
                }
                else
                {
                    dc.ExecuteNonQuery();
                }
                //獲取返回值
                foreach (SqlParameter sp in dc.Parameters)
                {
                    if (sp.Direction == ParameterDirection.Output || sp.Direction == ParameterDirection.InputOutput || sp.Direction == ParameterDirection.ReturnValue)
                    {
                        rtn.SetValue(sp.ParameterName.Replace("@", ""), sp.Value);
                    }
                }

                rtn.IsSuccess = true;
            }
            finally
            {
                if (ddr != null)
                {
                    ddr.Close();
                    ddr.Dispose();
                }
                dc.Dispose();
                dc = null;
            }

            return(rtn);
        }
コード例 #2
0
ファイル: OracleAccess.cs プロジェクト: redwolf0817/EFFC3.0
        public override DBDataCollection ExcuteProcedure(string sp_name, bool isReturnDataSet, ref DBOParameterCollection dbp)
        {
            DBDataCollection rtn = new DBDataCollection();

            rtn.IsSuccess = false;
            if (_s == DBStatus.Close)
            {
                DoOpen();
            }

            DataSetStd    ds = new DataSetStd();
            OracleCommand dc = null;

            if (this._s == DBStatus.Begin_Trans)
            {
                dc             = new OracleCommand(sp_name, conn);
                dc.Transaction = tran;
            }
            else
            {
                dc = new OracleCommand(sp_name, conn);
            }
            dc.CommandType = CommandType.StoredProcedure;
            FillParametersToCommand(dc, dbp);
            try
            {
                if (isReturnDataSet)
                {
                    OracleDataAdapter sqlDa = new OracleDataAdapter();
                    sqlDa.SelectCommand = dc;
                    sqlDa.Fill(ds);
                    rtn.ReturnDataSet = ds;
                }
                else
                {
                    dc.ExecuteNonQuery();
                }
                //獲取返回值
                foreach (OracleParameter sp in dc.Parameters)
                {
                    if (sp.Direction == ParameterDirection.Output || sp.Direction == ParameterDirection.InputOutput || sp.Direction == ParameterDirection.ReturnValue)
                    {
                        rtn.SetValue(sp.ParameterName.Replace(":", ""), sp.Value);
                    }
                }

                rtn.IsSuccess = true;
            }
            finally
            {
                dc.Cancel();
                dc = null;
            }

            return(rtn);
        }