Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 21st, 2011, 12:07 PM
Friend of Wrox
Points: 550, Level: 8
Points: 550, Level: 8 Points: 550, Level: 8 Points: 550, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , , .
Posts: 112
Thanks: 12
Thanked 0 Times in 0 Posts
Default set rs to a variable

Hi to all...
i'm having an issue with the following... it doesn't like
var Counter = rs("Counter1")
line...

Set rs = connDB.Execute("sp_GetCounter")
If not rs.eof Then
Do until rs.eof
var Counter = rs("Counter1")
rs.MoveNext
Loop
End If
Set rs = Nothing

if i comment out the line i get no errors...
i'm i doing somthing wrong???

thank you in advance
Rino
Reply With Quote
  #2 (permalink)  
Old December 22nd, 2011, 06:25 AM
Authorized User
Points: 448, Level: 7
Points: 448, Level: 7 Points: 448, Level: 7 Points: 448, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 86
Thanks: 1
Thanked 12 Times in 12 Posts
Default

Hi,

two things.

first, to declare a variable in vbscript you have to use the "Dim" keyword.
Second, in vbscript you must declare a variable first before using it.
So either on two lines or on one line with a colon as end-of-line separator.
Code:
 
Dim Counter : Counter = rs("Counter1")
Since you use it in a loop, declaring it separately is the obvious choice.
The following should work for you:
Code:
 
Dim Counter 
Set rs = connDB.Execute("sp_GetCounter")
  If not rs.eof Then
    Do until rs.eof
    Counter = rs("Counter1")
    rs.MoveNext
  Loop
End If
Set rs = Nothing
Reply With Quote
The Following User Says Thank You to disel2010 For This Useful Post:
RinoDM (March 29th, 2012)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable not set or With Block not set brucechess BOOK: Beginning VB.NET Databases 1 March 3rd, 2009 07:30 AM
Object variable or With block variable not set tparrish Pro VB Databases 1 May 25th, 2005 02:08 PM
Object variable or With block variable not set tparrish VB Databases Basics 1 May 25th, 2005 10:25 AM
Object variable or With block variable not set tparrish Classic ASP Databases 0 May 21st, 2005 06:48 AM
Set Rs = Cm.Execute riga Classic ASP Databases 4 April 7th, 2004 04:05 PM



All times are GMT -4. The time now is 12:28 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.