'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
Solution 1:[1]
This is for your information, please correct me if I am wrong:
Ways of connecting to DB:
- Check ODBC driver is available.
- If yes, create DSN(System DSN) in the adminstration tools in control panel.
- Use the code: Set con=createobject("adodb.connection") con.open "DSN=''"
- Execute the query
- Check ODBC driver is available.
- If not able to do DSN then Go to environmental variable and then Set Path=""
- 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;"
- Execute Query
Hope this helps. Correct me guys if I am wrong anywhere, as I am still learning.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
