Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2011, 12:07 PM
Friend of Wrox
 
Join Date: Oct 2006
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
 
Old December 22nd, 2011, 06:25 AM
Authorized User
 
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
The Following User Says Thank You to disel2010 For This Useful Post:
RinoDM (March 29th, 2012)





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





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