Sent: Tuesday, March 07, 2006 4:47 PM
Subject: [ODBC] Postgre and Visual Basic
>i need a sample of Visual Basic Project with PostgreSQL, anyone can help me?
>Trim's
This Sample function make a connection to database :
-------------------------------------------------------------------------------------
Public Function SystemLogon() As String
Dim MyConn As New ADODB.Connection, myDSN As String, Rs As Object
On Error GoTo Hata
MyConn.Open "Provider=MSDASQL.1;Password=" & ConnSifre & ";Persist Security Info=True;UID=" & ConnUser & ";Data Source=" & ConnDataSource & ";DATABASE=" & ConnDataBase & ";SERVER=" & ConnServer & ""
Set SetMyConn = MyConn
SystemLogon = ""
Exit Function
Hata:
SystemLogon = MyConn.Errors(0).Description
End Function
This Sample function executes a string (update,insert,delete) and returns number of effected rows :
------------------------------------------------------------------------------------
Public Function ExecuteSQL(pSQLStr As String) As Long
Dim AffectedRecords As Long
MyCurConn.Execute pSQLStr, AffectedRecords, adCmdText
ExecuteSQL = AffectedRecords
End Function
This Sample function executes a string (select) and returns a ADODB.recordset :
-----------------------------------------------------------------------------------------------------------------------
Public Function ExecuteSQLReturnRowSet(pSQLStr As String) As ADODB.Recordset
Dim MyRs As ADODB.Recordset
Set MyRs = New ADODB.Recordset
MyRs.CursorLocation = adUseClient
MyRs.Open pSQLStr, MyCurConn, adOpenStatic, adLockReadOnly
Set ExecuteSQLReturnRowSet = MyRs
Set MyRs = Nothing
End Function