如何通过C#连接到带有ssh隧道的远程PostgreSQL服务器

时间:2016-11-23 13:57:37

标签: c# postgresql ssh ado.net

我尝试连接到远程PostgreSQL服务器我有Host nameUser Name Password用于连接到数据库,除了我有ssh参数SSH host nameSSH portSSH 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

0 个答案:

没有答案