user3494938
user3494938

Reputation: 67

How to Connect to the Oracle DB using VBscript

So far I have the following code

Dim strConnect
Dim adoConnection
Dim adoRecordset
Dim strSQL
Dim strResults
strSQL = "SELECT COUNT(distinct party_id) FROM apps.per_all_people_f"
strConnect = "Provider=OraOLEDB.Oracle.1; Password=pwd; Persist Security Info=True; User      ID=user; Data Source=source; Extended Properties="""
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Open strConnect
Set adoRecordset = CreateObject("ADODB.Recordset")
adoRecordset.ActiveConnection = adoConnection 
adoRecordset.Source = strSQL
adoRecordset.Open
Do Until adoRecordset.EOF
        strResults = adoRecordset.Fields(0).Value
        msgbox strResults
        adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

Help me on correcting above code where I need to connect to Oracle DB and process some steps based on out data.

Im getting following error message.

Arguments are of the wrong type, are out of acceptable range, or are in conflict with another. Line 9 Source: ADODB.Connection

Upvotes: 2

Views: 30092

Answers (1)

Srekk
Srekk

Reputation: 136

This is for your information, please correct me if I am wrong:

Ways of connecting to DB:

  1. Check ODBC driver is available.
  2. If yes, create DSN(System DSN) in the adminstration tools in control panel.
  3. Use the code: Set con=createobject("adodb.connection") con.open "DSN=''"
  4. Execute the query

  1. Check ODBC driver is available.
  2. If not able to do DSN then Go to environmental variable and then Set Path=""
  3. Use the code: Set con=createobject("adodb.connection") or Set con=createobject("oledb.connection") con.open "Driver={Microsoft ODBC for Oracle};Server=; Uid=your_username;Pwd=your_password;"
  4. Execute Query

Hope this helps. Correct me guys if I am wrong anywhere, as I am still learning.

Upvotes: 0

Related Questions