Hello everyone,
First of all, I am new to scripting and I am trying to learn it on my own using books and the internet. Right now I am trying to write a program that will open an existing access database, copy (reverse order preferably) the data out of one column of a table to a text file. I then intend on searching the text file for needed information.
My question is, I think I can get the database opened, I just can't seem to get the data written to the text file. I have pasted some code that I am using, the database name is eventlogs, the table name is eventtable, and the column I need to search is called "type" without the quotes and "Error" is what I am searching for.
-------------------------------------
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = "C:\eventlogs.mdb"
objRecordSet.Open "SELECT * FROM EventTable " & _
"WHERE Type = 'Error'", objConnection, adOpenStatic, _
adLockOptimistic
objRecordSet.MoveFirst
Do Until objRecordset.EOF = True
objRecordset.Writeline("C:\file.txt")
objRecordset.MoveNext
Loop
objRecordSet.Close
objConnection.Close
--------------------------------------
I apologize if this post is incorrectly posted or does not have enough information. This is my first post here.
Thank you for your help.
Pete
First of all, I am new to scripting and I am trying to learn it on my own using books and the internet. Right now I am trying to write a program that will open an existing access database, copy (reverse order preferably) the data out of one column of a table to a text file. I then intend on searching the text file for needed information.
My question is, I think I can get the database opened, I just can't seem to get the data written to the text file. I have pasted some code that I am using, the database name is eventlogs, the table name is eventtable, and the column I need to search is called "type" without the quotes and "Error" is what I am searching for.
-------------------------------------
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = "C:\eventlogs.mdb"
objRecordSet.Open "SELECT * FROM EventTable " & _
"WHERE Type = 'Error'", objConnection, adOpenStatic, _
adLockOptimistic
objRecordSet.MoveFirst
Do Until objRecordset.EOF = True
objRecordset.Writeline("C:\file.txt")
objRecordset.MoveNext
Loop
objRecordSet.Close
objConnection.Close
--------------------------------------
I apologize if this post is incorrectly posted or does not have enough information. This is my first post here.
Thank you for your help.
Pete