RE:Conectar visual basic a postgresql en un servid
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
CadCon = ""
CadCon = CadCon + "DRIVER={PostgreSQL}; "
CadCon = CadCon + "SERVER=tera; "
CadCon = CadCon + "PORT=5432; "
CadCon = CadCon + "DATABASE=sfics; "
CadCon = CadCon + "UID=" & Trim(Te1.Text) & "; "
CadCon = CadCon + "PWD=" & Trim(Te2.Text) & "; "
cn.ConnectionString = CadCon
cn.Open
Set rs = New ADODB.Recordset
rs.ActiveConnection = cn
rs.CursorType = adOpenKeyset
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Open "select * from aproductos order by ID_Produ"
Set DataGrid1.DataSource = rs
DataGrid1.Refresh