其实跟java使用JDBC差不多
- 下载一个Npgsql.dll,然后在项目中添加引用Npgsql。
- 配置连接数据库的参数:
这些参数最好设置为静态变量,可共享数据。
private static bool dbIsOpen = false;//数据库是否已经打开
private static string server = "服务器地址";
private static string port = "5432";
private static string database = "库名";
private static string username = "用户名";
private static string password = "密码"