private void Task_Click(object sender, EventArgs e)
        {            conn = new SQLiteConnection();
            String ConnString = String.Empty;
            ConnString = "Data Source=Data.s3db;New=False;Compress=True;Synchronous=Off;UTF8Encoding=True;Version=3";
 
            String sql = String.Empty;
            sql = " select mail_title from mail_table";
            //Functions.SqliteExcute.TaskFillListView(this.TaskList, sql ,conn);
            SQLiteCommand cmd = new SQLiteCommand();
            cmd.Connection = conn;
            cmd.CommandText = sql;
            conn.Open();
            SQLiteDataReader read = cmd.ExecuteReader();            this.TaskList.Items.Clear();            while (read.Read())
            {
                ListViewItem items = new ListViewItem();
                items.SubItems.Clear();
                items.Text = read[0].ToString();
                TaskList.Items.Add(items);
            }
            read.Close();
            conn.Close();        }
值包含中文,可顯示的都是亂碼,等高人解答。

解决方案 »

  1.   

    显示的时候,是因为你的页面编码跟文件本身的编码不一致吧,你把页面编码改成utf-8试试,如果是数据库的中变成乱码了,需要更改数据库的编码
      

  2.   

     
    private void Task_Click(object sender, EventArgs e)
            {            conn = new SQLiteConnection();
                String ConnString = String.Empty;
                ConnString = "Data Source=Data.s3db;New=False;Compress=True;Synchronous=Off;UTF8Encoding=True;Version=3";
     
                String sql = String.Empty;
                sql = " select mail_title from mail_table";
                //Functions.SqliteExcute.TaskFillListView(this.TaskList, sql ,conn);
                SQLiteCommand cmd = new SQLiteCommand();
                cmd.Connection = conn;
                cmd.CommandText = sql;
                conn.Open();
                SQLiteDataReader read = cmd.ExecuteReader();            this.TaskList.Items.Clear();            while (read.Read())
                {
                    ListViewItem items = new ListViewItem();
                    items.SubItems.Clear();
                    items.Text = read[0].ToString();
                    TaskList.Items.Add(items);
                }
                read.Close();
                conn.Close();        }
    应该是编码问题吧~!!!
      

  3.   

     a = Encoding.GetEncoding("utf-8").GetString(Encoding.GetEncoding("utf-8").GetBytes(read[0].ToString()));
    items.Text = a;
    那該怎麼轉呢,我加了轉為utf8,可雖還是亂碼。不行哦``
      

  4.   

    2楼的方法是正确的,每新写连接时都得加上 UTF8Encoding=True; 
      

  5.   

    加上 UTF8Encoding=True; 不行啊