myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


           



Help with script to query spreadsheet

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> VB Script >> Help with script to query spreadsheet Page: [1]
Login
Message << Older Topic   Newer Topic >>
Help with script to query spreadsheet - 4/29/2008 2:46:50 PM   
ggreen681


Posts: 53
Score: 3
Joined: 9/24/2001
From: Cleveland, OH
Status: offline
The script is supposed to read the values of the Excel spreadsheet and list the results in the command window however it just hangs.  It never returns any data.

I am testing the script on XP Pro SP2 and the spreadsheet is Excel 2003

If it matters any here are the column headings in the script
Server, OS, Domain, GroupName, EnvName, FileName, FilePath, FileVersion

On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

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

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
   "Data Source=C:\Temp\TestBook.xls;" & _
       "Extended Properties=""Excel 8.0;HDR=Yes;"";"
objRecordset.Open "Select * FROM [Sheet1$] Where Server = Server01", _
   objConnection, adOpenStatic, adLockOptimistic, adCmdText

Do Until objRecordset.EOF
   Wscript.Echo objRecordset.Fields.Item("Server"), _
       objRecordset.Fields.Item("OS"), _
       objRecordset.Fields.Item("Domain"), _
       objRecordset.Fields.Item("GroupName"), _
       objRecordset.Fields.Item("EnvName"), _
       objRecordset.Fields.Item("FileName"), _
       objRecordset.Fields.Item("FilePath"), _
       objRecordset.Fields.Item("FileVersion")
   objRecordset.MoveNext
Loop

_____________________________

You mean that was a PRODUCTION server?!
Post #: 1
RE: Help with script to query spreadsheet - 4/30/2008 8:05:09 AM  1 votes
akaplan


Posts: 168
Score: 20
Joined: 4/22/2003
From: North Carolina
Status: offline
The criteria should be in single quotes:
"Select * FROM [Sheet1$] Where Server = 'Server01'"

Alan

(in reply to ggreen681)
Post #: 2
RE: Help with script to query spreadsheet - 4/30/2008 8:21:51 AM   
ggreen681


Posts: 53
Score: 3
Joined: 9/24/2001
From: Cleveland, OH
Status: offline
Perfect.... that took care of it

Thanks

_____________________________

You mean that was a PRODUCTION server?!

(in reply to akaplan)
Post #: 3
Page:   [1]
All Forums >> [Scripting Technologies] >> VB Script >> Help with script to query spreadsheet Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.219