예제 #1
0
 private static string createMessageJSONStr(Message message)
 {
     return "{\"isSuccess\":" + message.isSuccess.ToString().ToLower()
         + ",\"recordsAffected\":" + message.recordsAffected
         + ",\"returnValue\":" + message.returnValue
         + ",\"rows\":" + message.rows
         + ",\"errMsg\":\"" + message.errMsg + "\"}";
 }
예제 #2
0
        public static Message dataTableUpdate(string procedureName, DataTable dt)
        {
            Message m = new Message();
            try
            {
                SqlConnection conn = new SqlConnection(dbConnection.ConnectionString);
                using (conn)
                {
                    SqlCommand cmd = new SqlCommand(procedureName, conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlParameter tvparam = cmd.Parameters.AddWithValue("@tt", dt);
                    tvparam.SqlDbType = SqlDbType.Structured;
                    SqlParameter retval = new SqlParameter();
                    retval.ParameterName = "@return_value";
                    retval.SqlDbType = SqlDbType.Int;
                    retval.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(retval);
                    conn.Open();
                    m.recordsAffected = cmd.ExecuteNonQuery();
                    m.returnValue = Convert.ToString(retval.Value);
                    conn.Close();
                }
                conn.Dispose();
                m.isSuccess = true;
            }
            catch (SqlException ex)
            {
                m.errNumber = ex.ErrorCode;
                m.errMsg = ex.Message;
                logError(ex.ErrorCode, procedureName + ",params:" + DataTableToJSON(dt), ex.Message, "E");
            }
            catch (Exception ex)
            {
                m.errMsg = ex.Message;
                logError(null, procedureName + ",params:" + DataTableToJSON(dt), ex.Message, "E");
            }
            return m;

        }