c# 连接postgresql出现乱码问题

图片说明

public partial class test : System.Web.UI.Page
{
    private readonly string _strConn = "Server=192.168.0.107;Port=5432;User Id=postgres;Password=123;Database=TestDB;";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            NpgsqlConnection conn = new NpgsqlConnection(_strConn);
            conn.Open();
            string sql = "select count(*) from Tdb";
            NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
            int n = cmd.ExecuteNonQuery();
            conn.Close();
            if (n > 0)
            {
                Label1.Text = "yes";
            }
            else
            {
                Label1.Text = "no";
            }
        }
        catch (Exception ex)
        {

            Label1.Text = ex.Message;
        }
    }
}

    问题和代码都在这里了 求大神

pg-hba.conf在Postgresql的存放data的目录下的文件,你可以把这个文件打开,然后把md5的字样修改成trust就可以不用密码登陆了。

host all all 127.0.0.1/32 md5
修改成
host all all 127.0.0.1/32 trust

http://blog.csdn.net/psarvin2014/article/details/20550867