Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Loop through Northwind records

Reply
 
Old 07-30-2008   #1 (permalink)
richard


 
 

Loop through Northwind records

Hi All.

I'm trying to do something verysimple with vbscript: open a Northwind
table and loop through the recordset, echoing a field as I do so. Here
is what I'm attempting. The problem is that I can't find the syntax
documented for how to get to the fields of a recordset. The
'FieldByName' part, I made up, to illustrate what I'm trying to do.

Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Northwind;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Employees" , objConnection,
adOpenStatic, adLockReadOnly
do while not objRecordset.eof

'the problem is here
wscript.echo objRecordset.FieldByName("Last Name")

objRecordset.MoveNext
loop
objRecordset.Close
objConnection.Close

Could anyone direct me to either an example or to where I can find
documentation?

Thanks,
Richard

My System SpecsSystem Spec
Old 07-30-2008   #2 (permalink)
richard


 
 

Re: Loop through Northwind records

On Wed, 30 Jul 2008 13:09:42 -0500, "McKirahan" <News@xxxxxx>
wrote:
Quote:

>Basically, objRecordset.FieldByName("Last Name")
>should be objRecordset("Last Name").Value
Thanks McKirahan.
That's exactly what I was looking for.

Richard
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Mic only records left audio Sound & Audio
No MX or A records for .... Vista mail
First 400 Records in SQL Statement VB Script
dns scavenging records process PowerShell
How to add new records to EventLog? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46