VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Connects to Oracle databases and queries using Oledb and ADO. Very simmple and effective way to que

by N.K.Velu (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 31st August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Connects to Oracle databases and queries using Oledb and ADO. Very simmple and effective way to query Oracle databases!

API Declarations


' included them all in the code below. Create a new vb project. On the form
' create a button and a list box. Name the button as "cmdOracle" and the list
' box as "lstOracle". Cut and paste the code below in the click procedure of
' the button you have created. Click the button and your query will be
' displayed in the list box!

Rate Connects to Oracle databases and queries using Oledb and ADO. Very simmple and effective way to que



    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim sql As String
    
    
    lstOracle.Clear
       
    On Error GoTo eh
    'replace xxx with the oracle user id, yyy with password and zzz with
    'the database/instance name
    cn.Open "Provider=MSDAORA;User ID=xxx;Password=yyy;Data Source=zzz"
    
    'replace with an appropriate sql query.  I am querying a table called error
    'below
    
    sql = "SELECT * from error"
    
    rs.Open sql, cn, adOpenDynamic, adLockPessimistic
    While Not rs.EOF
        'replace Error_id with an appropriate column name of your table
        lstOracle.AddItem rs!Error_id
        rs.MoveNext
    Wend
    Set rs = Nothing
    Set cn = Nothing
Exit Sub
eh:
    MsgBox Err.Description, vbCritical, "Error"
    
End Sub

Download this snippet    Add to My Saved Code

Connects to Oracle databases and queries using Oledb and ADO. Very simmple and effective way to que Comments

No comments have been posted about Connects to Oracle databases and queries using Oledb and ADO. Very simmple and effective way to que. Why not be the first to post a comment about Connects to Oracle databases and queries using Oledb and ADO. Very simmple and effective way to que.

Post your comment

Subject:
Message:
0/1000 characters