我尝试连接到远程PostgreSQL服务器我有Host name
,User Name
Password
用于连接到数据库,除了我有ssh参数SSH host name
,SSH port
, SSH user
名称和SSH password
。
我尝试使用Npgsql
连接到数据库
使用以下代码
using (NpgsqlConnection conn = new NpgsqlConnection("Server=Host name;User Id=User Name;Password=XXXX;Database=XXXX;Port=5432"))
{
conn.Open();
using (NpgsqlCommand cmd = new NpgsqlCommand("select cplid from couple_fixed_extdata where col_10='151902' and col_2='197119';", conn))
{
using (NpgsqlDataReader reader = cmd.ExecuteReader())
{
List<int> couples = new List<int>();
while (reader.Read())
{
couples.Add(reader.GetInt32(0));
}
}
}
}
但我错了no pg_hba.conf entry for host XXXX, user XXXX, database XXXX, SSL off