Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Query SQL help

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,48415
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Query SQL help
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Query SQL help - 6/18/2007 1:51:30 AM   
  4scriptmoni


Posts: 208
Score: 0
Joined: 5/3/2007
Status: offline
I created a function to check if a value is within my DB, its a basic select

then the value is found great but when the query runs and no result is found I am not able to
get that step into my code.


      

thanks

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net
 
 
Post #: 1
 
 RE: Query SQL help - 6/18/2007 3:26:09 AM   
  ehvbs

 

Posts: 2197
Score: 50
Joined: 6/22/2005
From: Germany
Status: online
Hi 4scriptmoni,

check for EOF first, then either loop over the records found or indicate "not found":

function checkER(strEMAIL) 

  strQuery = "select * from SearchString where Id = '53' and Value = '" & strEMAIL & "'"
  objRecordSet.Open strQuery, objConnection, adOpenDynamic, adLockOptimistic
 
  If objRecordSet.eof Then
      wscript.echo strEMAIL & " NOT Found in ER!!!!!"
       checkER = False
  Else
    Do Until objRecordSet.eof
         wscript.echo "Result : " & objRecordSet(0)   'IF strEMAIL dont Exist code does not arriave here!!!!
          objRecordSet.MoveNext
     loop
     checkER = True
  End If
end function

[not tested]

Good luck!

ehvbs

(in reply to 4scriptmoni)
 
 
Post #: 2
 
 RE: Query SQL help - 6/18/2007 3:49:39 AM   
  4scriptmoni


Posts: 208
Score: 0
Joined: 5/3/2007
Status: offline
Perfect!!! thank you



_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: Query SQL help - 6/24/2007 7:27:12 PM   
  4scriptmoni


Posts: 208
Score: 0
Joined: 5/3/2007
Status: offline
Now I also need to the value of the select.

I have tried
strQueryR = objRecordSet(0).value  (always 0 ) and not the real query result

also tried
strQueryR = objRecordSet(0).Fields("Entit")

and I get
Microsoft VBScript runtime error: Object doesn't support this property or method: 'objRecordSet(...).Fields'

Anyone can help me out?

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to ehvbs)
 
 
Post #: 4
 
 RE: Query SQL help - 6/24/2007 7:29:49 PM   
  4scriptmoni


Posts: 208
Score: 0
Joined: 5/3/2007
Status: offline
duh... I got it working now.

strQueryR = objRecordSet.Fields("Entity")

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to 4scriptmoni)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Query SQL help 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