在用.net对sybase进行操作的时候,输入的汉字在数据库显示为乱码.
读出来的时候也是乱码.
怎么可以解决这个问题,sybase数据库是12.5版本的!

解决方案 »

  1.   

    转一下字符看可以不。
    // AttributesTutorial.cs
    // 此示例显示类和方法属性的用法。using System;
    using System.Reflection;
    using System.Collections;// IsTested 类是一个用户定义的自定义属性类。
    // 它可应用于任何声明,包括
    //  - 类型(结构、类、枚举、委托)
    //  - 成员(方法、字段、事件、属性、索引器)
    // 它在使用时不带参数。
    public class IsTestedAttribute : Attribute
    {
        public override string ToString()
        {
            return "Is Tested";
        }
    }// AuthorAttribute 类是一个用户定义的属性类。
    // 它仅可应用于类和结构声明。
    // 它带有一个未命名的字符串参数(作者的姓名)。
    // 还带有一个可选的命名参数 Version,其类型是 int。
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
    public class AuthorAttribute : Attribute
    {
        // 此构造函数指定属性类的未命名参数。
        public AuthorAttribute(string name)
        {
            this.name = name;
            this.version = 0;
        }    // 该属性为只读(它没有 set 访问器)
        // 因此它不能用作此属性的命名参数。
        public string Name 
        {
            get 
            {
                return name;
            }
        }    // 该属性为读写(它具有 set 访问器)
        // 因此当将此类用作属性类时
        // 它可用作命名参数。
        public int Version
        {
            get 
            {
                return version;
            }
            set 
            {
                version = value;
            }
        }    public override string ToString()
        {
            string value = "Author : " + Name;
            if (version != 0)
            {
                value += " Version : " + Version.ToString();
            }
            return value;
        }    private string name;
        private int version;
    }// 在此处将 AuthorAttribute 用户定义的自定义属性附加到
    // Account 类。当创建属性时,未命名的字符串参数将被传递到
    // AuthorAttribute 类的构造函数。
    [Author("Joe Programmer")]
    class Account
    {
        // 将 IsTestedAttribute 自定义属性附加到此方法。
        [IsTested]
        public void AddOrder(Order orderToAdd)
        {
            orders.Add(orderToAdd);
        }    private ArrayList orders = new ArrayList();
    }// 将 AuthorAttribute 和 IsTestedAttribute 自定义属性
    // 附加到此类。
    // 注意 AuthorAttribute 的“Version”命名参数的使用。
    [Author("Jane Programmer", Version = 2), IsTested()]
    class Order
    {
        // 在此处添加资料...
    }class MainClass
    {
       private static bool IsMemberTested(MemberInfo member)
       {
            foreach (object attribute in member.GetCustomAttributes(true))
            {
                if (attribute is IsTestedAttribute)
                {
                   return true;
                }
            }
          return false;
       }    private static void DumpAttributes(MemberInfo member)
        {
            Console.WriteLine("Attributes for : " + member.Name);
            foreach (object attribute in member.GetCustomAttributes(true))
            {
                Console.WriteLine(attribute);
            }
        }    public static void Main()
        {
            // 显示 Account 类的属性
            DumpAttributes(typeof(Account));        // 显示已测试成员的列表
            foreach (MethodInfo method in (typeof(Account)).GetMethods())
            {
                if (IsMemberTested(method))
                {
                   Console.WriteLine("Member {0} is tested!", method.Name);
                }
                else
                {
                   Console.WriteLine("Member {0} is NOT tested!", method.Name);
                }
            }
            Console.WriteLine();        // 显示 Order 类的属性
            DumpAttributes(typeof(Order));        // 显示 Order 类上的方法的属性
            foreach (MethodInfo method in (typeof(Order)).GetMethods())
            {
               if (IsMemberTested(method))
               {
                   Console.WriteLine("Member {0} is tested!", method.Name);
               }
               else
               {
                   Console.WriteLine("Member {0} is NOT tested!", method.Name);
               }
            }
            Console.WriteLine();
        }
    }
      

  2.   

    这个问题有人问过了;
    不知楼主知不知道MS的垄断行为,ORACLE都开发了自已的连接自已数据库的组件,你就会明白为什么MS的连接SYBASE数据为什么会有问题了
      

  3.   

    那怎么可以解决这个问题呢
    zjh135(aaa)
      

  4.   

    虽然我能搞定Sybase服务器,但我搞不定.Net啊,使用了utf-8编码都不行,呵呵。是不是没人会啊?中国好像很大呢.........
      

  5.   

    把System.Text.Encoding中的编码都试一遍,我就不信没有一个能用的?除非程序有问题。
      

  6.   

    已经搞定,是sybase数据库本身字符集的问题!