Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

how to connect to oracle in vb6 (sql statement)


thanks
0
turbot_yu
Asked:
turbot_yu
  • 2
4 Solutions
 
Bob LambersonSoftware EngineerCommented:
0
 
Ryan ChongCommented:
I'm using this module to deal with database... see if it may helpful to you as well:


'Version 1.1.13
'Author: Chong Yit Seng (ryancys @ g mail com)
'Last Updated: 2 Mar 2006

Public Enum ComboCompareUsing
    itemData = 1
    Text = 2
End Enum

Public conn As ADODB.Connection
Public rs As ADODB.Recordset
Public SQLstr As String
Public modconnString As String
Public cmd As ADODB.Command

Public Sub setConnString(ConnString As String)
    modconnString = ConnString
End Sub

'Ver 1.3
Public Function OpenConn(xconn As ADODB.Connection, Optional ConnString As String = "", Optional remainOpenIfAlreadyOpened As Boolean = False) As Boolean
    On Error GoTo EH
    'Open Connection
    If Not xconn Is Nothing Then
        If xconn.state = adStateOpen Then
            If remainOpenIfAlreadyOpened Then
                OpenConn = True
                Exit Function
            Else
                xconn.Close
            End If
        End If
    End If
   
    Set xconn = New ADODB.Connection
    xconn.ConnectionString = IIf(ConnString = "", modconnString, ConnString)
    xconn.CursorLocation = adUseClient
    xconn.Open
    OpenConn = (xconn.state = adStateOpen)
    Exit Function
EH:
    OpenConn = False
End Function

'Ver 1.1
Public Function CloseConn(xconn As ADODB.Connection) As Boolean
    On Error GoTo EH
    'Close Connection
    If Not xconn Is Nothing Then
        If xconn.state = adStateOpen Then xconn.Close
        Set xconn = Nothing
    End If
    CloseConn = True
    Exit Function
EH:
    CloseConn = False
End Function

'Ver 1.2
Public Function OpenRS(xrs As ADODB.Recordset, xconn As ADODB.Connection, ByVal SQL As String) As Boolean
    On Error GoTo EH
    'Open RecordSet
    If Not xconn Is Nothing Then
        If xconn.state = adStateClosed Then xconn.Open
        Set xrs = New ADODB.Recordset
        xrs.Open SQL, xconn, adOpenKeyset, adLockOptimistic
    End If
    OpenRS = (xrs.state = adStateOpen)
    Exit Function
EH:
    OpenRS = False
End Function

'Ver 1.1
Public Function CloseRS(xrs As ADODB.Recordset) As Boolean
    On Error GoTo EH
    'Close RecordSet
    If Not rs Is Nothing Then
        If rs.state = adStateOpen Then rs.Close
        Set rs = Nothing
    End If
    CloseRS = True
    Exit Function
EH:
    CloseRS = False
End Function

Public Function ReplaceQuote(v As String) As String
    ReplaceQuote = Replace$(v, "'", "''", , , vbTextCompare)
End Function

'Ver 1.1
Public Function formatSQLDate(d As Date, Optional formatString As String = "mm/dd/yyyy hh:nn:ss") As String
    formatSQLDate = Format$(d, formatString)
End Function

'Ver 1.0
Public Function formatEngDate(d As Date, Optional formatString As String = "dd/mm/yyyy") As String
    formatEngDate = Format$(d, formatString)
End Function
0
 
WimCommented:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now