Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Database Query

Status
Not open for further replies.

dukkse

Technical User
Oct 15, 2003
42
US
I have a simple question, I should now it, but somehow this is greyed out. .Kinda embarrassad about it but here goes..

I have the following script, and I just want to list all items in the "servers" list.


Const adOpenStatic = 3
Const adLockOptimistic = 3

Set wshshell = WScript.CreateObject("WScript.Shell")
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = \\spider\e$\Inetpub\

objRecordSet.Open "SELECT * FROM Servers" , _
objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
If Not objRecordset.EOF Then
WScript.Echo objRecordset
End If
objRecordSet.Close
objConnection.Close
WScript.Quit


Thanks
 
Provided Servers is a valid Table/Query in NTDatabase.mdb:
objRecordSet.Open "SELECT * FROM Servers" , _
objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
If Not objRecordset.EOF Then
s = ""
For i = 0 To objRecordset.Fields.Count - 1
s = s & "|" & objRecordset.Fields(i).Name
Next
WScript.Echo Mid(s, 2)
End If
While Not objRecordset.EOF
s = ""
For i = 0 To objRecordset.Fields.Count - 1
s = s & "|" & objRecordset.Fields(i)
Next
WScript.Echo Mid(s, 2)
objRecordSet.MoveNext
WEnd
objRecordSet.Close
objConnection.Close
WScript.Quit

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yo!!

Works awsome.. Thanks

/Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top