まず、データベースに接続する準備をします。
6行目の「Server=・・・」はデータベース接続文字列と呼ばれるものです。この例では、ソースコードに書いていますが、このような内容は、ソフトウェアの設定ファイルで述べたアプリケーション構成ファイルに書いたほうが良いでしょう。
検索ワード:postgres、データベース接続文字列
Public Class SeqValueDAO
Private _conn As NpgsqlConnection
Sub New()
_conn = New NpgsqlConnection("Server=localhost; Port=5432; Database=postgres; User Id=postgres; Password=postgres; POOLING=True; MINPOOLSIZE=10; MAXPOOLSIZE=20; Timeout=1024; CommandTimeout=1024;")
_conn.Open()
End Sub
End Class
検索ワード:postgres、データベース接続文字列
スポンサーリンク