我正在寻找从外部应用程序连接到Heroku Postgres数据库的最佳方式。该应用程序在asp.net中。我正在尝试使用NpgSQL,但获取证书未知错误。有人做过吗?你有什么建议吗?用Asp.Net连接到Heroku Postgres数据库
0
A
回答
1
我使用下面的连接字符串来连接的Heroku Postgres数据库:
string connString = "User ID=<user>;Password=<pass>;Host=<host>;Port=<port>;Database=<database>;Pooling=true;Use SSL Stream=True;SSL Mode=Require;TrustServerCertificate=True;"
其中<user>, <pass>, <host>, <port> and <database>
从Heroku的Postgres的应用程序设置值。端口默认为5432。
然后使用NpgSql我NpgsqlConnection的创建实例:
var conn = new NpgsqlConnection(connString);
Dafault样本:http://www.npgsql.org/doc/index.html
+0
对于那些将来阅读的人,我强烈建议您使用Heroku的Platform API以编程方式获取数据库URI - 您可以使用curl来获取数据库URI,您必须将您的身份验证令牌作为标头传递给它。 @Set的解决方案将起作用,但在某些情况下可能会中断。 – BKSpurgeon
相关问题
- 1. 如何连接到heroku postgres数据库?
- 2. 连接Django到Heroku Postgres数据库
- 3. ClojureScript,Heroku - 连接到Postgres数据库
- 4. 连接到postgres数据库
- 5. 使用Netbeans无法连接到heroku postgres数据库
- 6. 使用libpqxx连接到Postgres数据库
- 7. 连接到Heroku Postgres数据库时出现CertificateUnknown错误
- 8. 连接到的Heroku Postgres数据库需要很长的时间
- 9. 独角兽不断连接到heroku上的postgres数据库
- 10. 如何将PyCharm连接到Heroku postgres数据库
- 11. 无法连接到来自Homestead Vagrant框的Heroku Postgres数据库
- 12. Heroku Postgres升级后,Flyway无法连接到数据库
- 13. Heroku的拒绝连接到Postgres数据库
- 14. 春季启动连接到Heroku上的Postgres数据库
- 15. C#postgres数据库连接
- 16. C#连接到Postgres数据库
- 17. 本地连接到HerokuConnect Postgres数据库
- 18. 无法连接到postgres数据库?
- 19. 连接到Heroku PostgreSQL数据库
- 20. 将Python连接到Heroku PostgresSQL数据库?
- 21. 远程连接到clearDB heroku数据库
- 22. 使用SSH(Putty)连接到Heroku Postgres
- 23. 无法连接运行在heroku上的postgres数据库
- 24. 的Heroku Postgres数据库 - 连接被拒绝
- 25. 无法将Appfuse Spring应用程序连接到Heroku Postgres数据库
- 26. 使用Play Framework无法连接到远程Heroku Postgres数据库2.2.2
- 27. 连接应用Postgres数据库
- 28. 使用ASP.NET连接到Access数据库
- 29. 用Web.config连接到mdf数据库ASP.NET
- 30. 无法连接到连接到heroku部署的MongoLab数据库
嗨。欢迎来到SO,你至少试过了什么?你能给我们一些开始代码来帮助你吗? – acostela
PostgreSQL运行SSL = on? – d1ll1nger