Richard
Tue May 09 11:25:52 CDT 2006
"Jens Lenge" <spampot@gmx.net> wrote in message
news:1147158660.048183.158160@y43g2000cwc.googlegroups.com...
> Thanks - I will have a look.
>
You need the syntax for a connection string for Oracle databases. See this
link:
http://www.connectionstrings.com/
You must assign your SQL statement to a string variable, which involves
enclosing it in quotes. The trick is to get the commas, spaces, and quotes
correct in the string. The code could be similar to below (I don't have an
Oracle db so I cannot test):
Option Explicit
Dim strConnnect, adoRecordset, strField1, strField2
' Connection string for Oracle database.
strConnect = "Driver={Microsoft ODBC for Oracle};" _
& "Server=OracleServer.world;" _
& "Uid=Username;" _
& "Pwd=asdasd;"
Set adoRecordset = CreateObject("ADODB.Recordset")
adoRecordset.ActiveConnection = strConnect
adoRecordset.Source = "SELECT Field1, Field2 " _
& "FROM MyTable " _
& "WHERE Field3 = 'Error'"
adoRecordset.Open
Do Until adoRecordset.EOF
strField1 = adoRecordset.Fields("Field1").Value
strField2 = adoRecordset.Fields("Field2").Value
Wscript.Echo strField1 & ", " & strField2
adoRecordset.MoveNext
Loop
adoRecordset.Close
adoConnection.Close
You can also use a Connection object. If I am modifying data, I use a
Command object. See ADO documentation for more.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab -
http://www.rlmueller.net