用 java 也三年了, 結果 microsoft 用戶端的程式,
還是習慣用 microsoft 的東西, 呵呵 Orz
不過 database 當然還是要用我習慣的 PostgreSQL,
只是沒想到 C# 與 PostgreSQL 不太馬吉, 還好有高人的指點
(ps. 高人 = google + 不知名的好心人)
順手將之記下, 以免日後又給他忘記了


postgreSql
1. 自 PostgreSQL download Npgsql (有分 mono, ms1, ms2) ^^
2. 當 Server Side 是用 utf-8 (Unicode) 時要在程式中 show 正確的中文(zh-TW)
要依以下的方式 :
參考 : http://archives.postgresql.org/pgsql-bugs/2004-04/msg00041.php
String connectionString = "Server=127.0.0.1;Port=5432;User Id=xxx;Password=xxx;Database=DBName;";
NpgsqlConnection conn = new NpgsqlConnection(connectionString);
NpgsqlCommand cmd = new NpgsqlCommand("set client_encoding TO big5", conn);
conn.Open(); --> 就是這段, 要先告訴 server client 是 big5
cmd.ExecuteNonQuery();
NpgsqlCommand command = new NpgsqlCommand(sqlCommand, conn);
NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();
adapter.SelectCommand = command;
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
adapter.Fill(table);
3. .Net 中有關國際化的 namespace : System.Globalization
參考 : http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx

identical 發表在 痞客邦 留言(0) 人氣()