示例#1
0
        public arrOutComPar executeProcNQ(string strProcName, sComParameter[] dtComParameter)
        {
            using (_con = new SqlConnection(connectionString))
            {
                _con.Open();

                _com                = new SqlCommand();
                _com.Connection     = _con;
                _com.CommandType    = CommandType.StoredProcedure;
                _com.CommandText    = strProcName;
                _com.CommandTimeout = getCommandTimeout();

                if (dtComParameter != null)
                {
                    foreach (sComParameter dComPar in dtComParameter)
                    {
                        //_com.Parameters.Add(dComPar.ParamName, dComPar.dbType, dComPar.Length,ParameterDirection.Input).Value = dComPar.Value;
                        if (dComPar.parDir == ParameterDirection.Input)
                        {
                            _com.Parameters.Add(dComPar.ParamName, dComPar.dbType, dComPar.Length).Value = dComPar.Value;
                        }
                        else
                        {
                            _com.Parameters.Add(dComPar.ParamName, dComPar.dbType, dComPar.Length).Direction = dComPar.parDir;
                        }
                    }
                }


                _com.Transaction = _con.BeginTransaction();

                Boolean error = false;

                try
                {
                    _com.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    error = true;
                    _com.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    if (error == false)
                    {
                        _com.Transaction.Commit();
                    }
                }


                arrOutComPar data = new arrOutComPar();
                data.getOutParam(dtComParameter, _com);
                _com.Dispose();
                return(data);
            }
        }
示例#2
0
        public DataRowCollection executeProcQR(string strProcName, sComParameter[] dtComParameter, ref arrOutComPar retval)
        {
            DataRowCollection data;

            using (_con = new SqlConnection(connectionString))
            {
                _con.Open();
                _com                = new SqlCommand();
                _com.Connection     = _con;
                _com.CommandType    = CommandType.StoredProcedure;
                _com.CommandText    = strProcName;
                _com.CommandTimeout = getCommandTimeout();
                foreach (sComParameter dComPar in dtComParameter)
                {
                    //_com.Parameters.Add(dComPar.ParamName, dComPar.dbType, dComPar.Length).Value = dComPar.Value;
                    if (dComPar.parDir == ParameterDirection.Input)
                    {
                        _com.Parameters.Add(dComPar.ParamName, dComPar.dbType, dComPar.Length).Value = dComPar.Value;
                    }
                    else
                    {
                        _com.Parameters.Add(dComPar.ParamName, dComPar.dbType, dComPar.Length).Direction = dComPar.parDir;
                    }
                }
                _com.Transaction = _con.BeginTransaction();
                Boolean error = false;

                try
                {
                    _xml = _com.ExecuteXmlReader();
                }
                catch (Exception ex)
                {
                    error = true;
                    _com.Transaction.Rollback();
                }
                finally
                {
                    if (error == false)
                    {
                        _com.Transaction.Commit();
                    }
                }

                data = createRows(_xml);

                retval = new arrOutComPar();
                retval.getOutParam(dtComParameter, _com);

                _com.Dispose();
            }

            return(data);
        }