sqlite怎么读不出中文来
1 using System;
2 using System.Data.SQLite;
3 using System.Configuration;
4 using System.Web;
5 using System.Web.Security;
6 using System.Web.UI;
7 using System.Web.UI.WebControls;
8 using System.Web.UI.WebControls.WebParts;
9 using System.Web.UI.HtmlControls;
10 using System.Data;
11
12 /// <summary>
13 /// sqlite 的摘要说明
14 /// </summary>
15 public class sqlite
16 {
17 SQLiteConnection con;
18 public sqlite()
19 {
20 //
21 // TODO: 在此处添加构造函数逻辑
22 //
23 con = new SQLiteConnection(@"Data Source=D:\My Documents\Visual Studio 2005\WebSites\ajaxtest\App_Data\news2.sqlite");
24 }
25 public void exesql(string cmdtxt)
26 {
27 SQLiteCommand cmd = new SQLiteCommand(cmdtxt, con);
28 con.Open();
29 cmd.ExecuteNonQuery();
30 con.Close();
31 }
32 public Table getre(string cmdtxt)
33 {
34 Table tb = new Table();
35 SQLiteCommand cmd = new SQLiteCommand(cmdtxt, con);
36 con.Open();
37 SQLiteDataReader dr=cmd.ExecuteReader();
38 while (dr.Read())
39 {
40 TableRow nrow = new TableRow();
41 for (int i = 0; i < dr.FieldCount; i++)
42 {
43 TableCell tc = new TableCell();
44 tc.Text = dr[i].ToString();
45 nrow.Cells.Add(tc);
46 }
47 tb.Rows.Add(nrow);
48 }
49 con.Close();
50 return tb;
51 }
52
53 }
54
自己写的sqlite操作类如上,使用命令行可以显示中文。自己调用方法如下
1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12 public partial class sltest : System.Web.UI.Page
13 {
14 protected void Page_Load(object sender, EventArgs e)
15 {
16 if (!IsPostBack)
17 {
18 sqlite sl = new sqlite();
19 //sl.exesql("insert into msg values(1,'sasdasd','asdlkjalksdjsd',2007-06-14)");
20 Table tb = sl.getre("select * from msg");
21 Response.Write(tb.Rows[0].Cells[1].Text);
22
23
24 }
25 }
26 }
27
编码UTF8和UTF16都试过,这是怎么回事呢?