Public gpgDB As ADODB.Connection
Function DbConnect(ip As String, db As String, user As String, password As String) As Boolean
On Error GoTo ThisEnd
Set gpgDB = Nothing
Set gpgDB = New ADODB.Connection
gpgDB.Open "Provider=PostgreSQL;Data Source=" + ip + ";location=" + db, user, password
If gpgDB.State = adStateClosed Then
MsgBox "Connect error!"
DbConnect = False
Exit Function
End If
DbConnect = True
ThisEnd:
End Function