コード例 #1
0
ファイル: SqlHelper.cs プロジェクト: wshardikdeshani/ADMRiya
        public MEMBERS.SQLReturnMessageNValue ExecuteProceduerWithMessageNValueSpecial(string ProceduerName, object obj, int ReturnTypeOutVal = 3)
        {
            MEMBERS.SQLReturnMessageNValue res = new MEMBERS.SQLReturnMessageNValue();

            try
            {
                SqlCommand cmd = new SqlCommand
                {
                    CommandText = ProceduerName,
                    Connection  = con,
                    CommandType = CommandType.StoredProcedure
                };
                SqlParameter[] param = new SQLPatameterClass().ConvertClassToSQLParams(obj);
                cmd.Parameters.AddRange(param);
                cmd.Parameters.Add("OUTVAL", (ReturnTypeOutVal == 1 ? SqlDbType.UniqueIdentifier : SqlDbType.Int)).Direction = ParameterDirection.Output;
                cmd.Parameters.Add("OUTMSG", SqlDbType.NVarChar, -1).Direction = ParameterDirection.Output;
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                cmd.ExecuteNonQuery();
                con.Close();
                res.Outval = cmd.Parameters["OUTVAL"].Value;
                res.Outmsg = cmd.Parameters["OUTMSG"].Value.ToString();
            }
            catch (Exception ee)
            {
                res.Outval = 0;
                res.Outmsg = "Error : " + ee.Message;
            }
            return(res);
        }
コード例 #2
0
ファイル: SqlHelper.cs プロジェクト: wshardikdeshani/ADMRiya
        public MEMBERS.SQLReturnMessageNValue ExecuteProceduerWithMessageNValue(string ProceduerName, object[,] ParamValue, int ReturnTypeOutVal = 3)
        {
            MEMBERS.SQLReturnMessageNValue res = new MEMBERS.SQLReturnMessageNValue();

            try
            {
                SqlCommand cmd = new SqlCommand
                {
                    CommandText = ProceduerName,
                    Connection  = con,
                    CommandType = CommandType.StoredProcedure
                };
                SqlParameter[] param = new SqlParameter[ParamValue.GetUpperBound(0) + 1];
                for (int i = 0; i < param.Length; i++)
                {
                    param[i] = new SqlParameter("@" + ParamValue[i, 0].ToString(), (ParamValue[i, 1] == null ? null : (ParamValue[i, 1].ToString() == "null" ? null : ParamValue[i, 1].ToString())));
                }
                cmd.Parameters.AddRange(param);
                cmd.Parameters.Add("OUTVAL", (ReturnTypeOutVal == 1 ? SqlDbType.UniqueIdentifier : SqlDbType.Int)).Direction = ParameterDirection.Output;
                cmd.Parameters.Add("OUTMSG", SqlDbType.NVarChar, -1).Direction = ParameterDirection.Output;
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                cmd.ExecuteNonQuery();
                con.Close();
                res.Outval = cmd.Parameters["OUTVAL"].Value;
                res.Outmsg = cmd.Parameters["OUTMSG"].Value.ToString();
            }
            catch (Exception ee)
            {
                res.Outval = 0;
                res.Outmsg = "Error : " + ee.Message;
            }
            return(res);
        }