Exemplo n.º 1
0
        public MEMBERS.SQLReturnValue ExecuteProceduerWithValueSpecial(string ProceduerName, object obj, int ReturnTypeOutVal = 3)
        {
            MEMBERS.SQLReturnValue res = new MEMBERS.SQLReturnValue();

            try
            {
                SqlCommand cmd = new SqlCommand
                {
                    CommandText = ProceduerName,
                    Connection  = con,
                    CommandType = CommandType.StoredProcedure
                };
                if (obj != null)
                {
                    SqlParameter[] param = new SQLPatameterClass().ConvertClassToSQLParams(obj);
                    cmd.Parameters.AddRange(param);
                }
                cmd.Parameters.Add("OUTVAL", (ReturnTypeOutVal == 1 ? SqlDbType.UniqueIdentifier : ReturnTypeOutVal == 2 ? SqlDbType.Int : SqlDbType.NVarChar), -1).Direction = ParameterDirection.Output;
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                cmd.ExecuteNonQuery();
                con.Close();
                res.Outval = cmd.Parameters["OUTVAL"].Value;
            }
            catch (Exception ee)
            {
                res.Outval = "Error : " + ee.Message;
            }
            return(res);
        }
Exemplo n.º 2
0
        public MEMBERS.SQLReturnValue ExecuteProcedureWithDatatable(string ProcedureName, DataTable tableValue
                                                                    , string TableParamName, object obj, int ReturnTypeOutVal = 3)
        {
            MEMBERS.SQLReturnValue res = new MEMBERS.SQLReturnValue();
            SqlCommand             cmd = new SqlCommand
            {
                CommandText = ProcedureName,
                Connection  = con,
                CommandType = CommandType.StoredProcedure
            };

            SqlParameter[] param = new SQLPatameterClass().ConvertClassToSQLParams(obj);
            cmd.Parameters.AddRange(param);
            if (tableValue != null)
            {
                SqlParameter tableParam = new SqlParameter("@" + TableParamName, tableValue)
                {
                    SqlDbType = SqlDbType.Structured
                };
                cmd.Parameters.Add(tableParam);
            }
            cmd.Parameters.Add("OUTVAL", (ReturnTypeOutVal == 1 ? SqlDbType.UniqueIdentifier : SqlDbType.Int)).Direction = ParameterDirection.Output;
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }
            cmd.ExecuteNonQuery();
            con.Close();
            res.Outval = cmd.Parameters["OUTVAL"].Value;
            return(res);
        }