现在我写了个存储过程,返回的错误消息是1,2,3。。(分别代表不同的错误消息)(这个存储过程是导入用户信息用的)
系统现在还有个存储过程,返回的错误消息也是1,2,3.。。(分别代表不同的错误消息)(这个存储过程是导入分组信息用的)
这两个存储过程不会同时调用,这两个存储过程调用时都调用的一个共通的导入信息方法,
我的问题是怎么才能使错误消息也共通化呢,拜托高手们了,在线等

解决方案 »

  1.   

    看我的:
     public static class PhpWebServerError
        {
            private static Dictionary<int, string> _phpError = new Dictionary<int, string>();
            public static Dictionary<int, string> PhpError
            {
                get
                {
                    if (_phpError.Count == 0)
                    {
                        InitDictionary();
                    }
                    return _phpError;
                }
            }        private static void InitDictionary()
            {
                _phpError.Add(0, "错误1");
                _phpError.Add(1, "错误2");
                _phpError.Add(2, ".。");
                _phpError.Add(3, "。。");
                _phpError.Add(4, "。。");
                _phpError.Add(5, "。。");
                _phpError.Add(6, "。。");
                _phpError.Add(7, "。。");
                _phpError.Add(8, "。。,。。");
                
            }        public static string FindError(int key)
            {
                foreach (KeyValuePair<int, string> kvp in PhpError)
                {
                    if (kvp.Key == key)
                    {
                        return kvp.Value;
                    }
                }
                return "未知错误";
            }
        }
      

  2.   

    dictionary保存键值对
    枚举enum取值
    public enum Status {}
    Enum.GetName(typeof(Status), int.Parse(index));
      

  3.   

    自己写的存储过程,返回的错误消息改成 Mine1,Mine2,Mine3。,有些系统里,错误信息只能是整数,就从某一个指定的值开始累加,如 2001,2002,2003...