PostgreSQLDatabase.Connect

From Xojo Documentation

Method

PostgreSQLDatabase.Connect(Optional additionalOptions As String = "") As Boolean

Supported for all project types and targets.

Connects to the database server and opens the database for access.

Before proceeding with database operations, test to be sure that Connect returns True.

Notes

The additionalOptions are passed to PostgreSQL as is and are not escaped in any way. The available options for this parameter are specified here: http://www.postgresql.org/docs/9.1/static/libpq-connect.html

To connect using SSL, use the SSLMode, SSLCertificate and SSLKey properties as appropriate for how your server is configured.

Example

This code attempts to connect to the "BaseballLeague" database on a PostgreSQL server:

Var db As New PostgreSQLDatabase
db.Host = "192.168.1.172"
db.Port = 5432
db.DatabaseName = "BaseballLeague"
db.UserName = "broberts"
db.Password = "streborb"
Try
db.Connect
// Use the database
Catch error As DatabaseException
// There was a database connection error
MessageBox(error.Message)
End If