473,765 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using GetRows()

I am getting information out of a table to place into to
an Array.
rs=DataConn.Exe cute(strSQL)

At this point I place it into the array

objArray=rs.Get Rows()

But how do I handle things if the rs came back blank?

What happens is that the loop encounters an error?


Jul 19 '05 #1
5 8178
"Croney69" <n@n.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
I am getting information out of a table to place into to
an Array.
rs=DataConn.Exe cute(strSQL)

At this point I place it into the array

objArray=rs.Get Rows()

But how do I handle things if the rs came back blank?

What happens is that the loop encounters an error?


If rs.RecordCount > 0 Then
objArray = rs.GetRows()
'do stuff with array
Else
'handle "no records" condition
End If

HTH-Jon

Jul 19 '05 #2
Sorry I should have mentioned this is a function to
provide an array, which is then use.

I am well a wear of the "if then else" and "eof".
What I want to know is that after calling my function
MyArray= GetInfo(sql)

I will know if to proceed or not depending on the result.

This is what I have seen but it dose not work

1. If not rs.eof then
2. ObjArray=rs.Get Rows()
3. Else
4. ObjArray=dataco nn.execute("Sel ect 'EOF'").GetRows ()
5. End if

I get an error on line 4
-----Original Message-----
You may want to use If Not rs.EOF Then aVar = rs.GetRows () with the codethat you're using.

Ray at home

--
Will trade ASP help for SQL Server help
"Jon Mundsack" <mu******@roche ster.rr.com> wrote in messagenews:bg******* *****@ID-168020.news.uni-berlin.de...
"Croney69" <n@n.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
> I am getting information out of a table to place into to > an Array.
> rs=DataConn.Exe cute(strSQL)
>
> At this point I place it into the array
>
> objArray=rs.Get Rows()
>
> But how do I handle things if the rs came back blank?
>
> What happens is that the loop encounters an error?


If rs.RecordCount > 0 Then
objArray = rs.GetRows()
'do stuff with array
Else
'handle "no records" condition
End If

HTH-Jon

.

Jul 19 '05 #3
"Croney69" <n@n.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
Sorry I should have mentioned this is a function to
provide an array, which is then use.

I am well a wear of the "if then else" and "eof".
What I want to know is that after calling my function
MyArray= GetInfo(sql)

I will know if to proceed or not depending on the result.

This is what I have seen but it dose not work

1. If not rs.eof then
2. ObjArray=rs.Get Rows()
3. Else
4. ObjArray=dataco nn.execute("Sel ect 'EOF'").GetRows ()
5. End if

I get an error on line 4


So, if rs contains records, you want ObjArray to contain the GetRows, and if
rs doesn't contain records, you want it to contain a single array element
holding the word EOF? If so, then this is what you want:

If not rs.eof then
ObjArray=rs.Get Rows()
Else
ReDim ObjArray(0)
ObjArray(0) = "EOF"
End if

I see no reason to involve the dataconn.execut e call and another GetRows,
unless I'm still missing something.

HTH-Jon

Jul 19 '05 #4
AFAIK you need to select FROM a table or other database object (view,
stored proc, etc). And, even if that line 4 syntax worked, you'd be
setting objArray to an array if it had records and a recordset if it
didn't, which will probably cause problems later.

I might set it up like this:
if not rs.EOF then
objArray = rs.GetRows()
else
dim objArray(1,1)
objArray(0,0) = "No Records" ' or whatever flag value you want
end if
Then, I could check objArray(0,0) for "No Records" before processing.

"Croney69" <n@n.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
Sorry I should have mentioned this is a function to
provide an array, which is then use.
I am well a wear of the "if then else" and "eof".
What I want to know is that after calling my function
MyArray= GetInfo(sql)
I will know if to proceed or not depending on the result.
This is what I have seen but it dose not work
1. If not rs.eof then
2. ObjArray=rs.Get Rows()
3. Else
4. ObjArray=dataco nn.execute("Sel ect 'EOF'").GetRows ()
5. End if

I get an error on line 4
-----Original Message-----
You may want to use If Not rs.EOF Then aVar = rs.GetRows

() with the code
that you're using.
Ray at home
--
Will trade ASP help for SQL Server help
"Jon Mundsack" <mu******@roche ster.rr.com> wrote in

message
news:bg******* *****@ID-168020.news.uni-berlin.de...
"Croney69" <n@n.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
> I am getting information out of a table to place into to > an Array.
> rs=DataConn.Exe cute(strSQL)
> At this point I place it into the array
> objArray=rs.Get Rows()
> But how do I handle things if the rs came back blank?
> What happens is that the loop encounters an error?
If rs.RecordCount > 0 Then
objArray = rs.GetRows()
'do stuff with array
Else
'handle "no records" condition
End If
HTH-Jon

Jul 19 '05 #5
Croney69 wrote:
I am getting information out of a table to place into to
an Array.
rs=DataConn.Exe cute(strSQL)

At this point I place it into the array

objArray=rs.Get Rows()

But how do I handle things if the rs came back blank?

What happens is that the loop encounters an error?


This is my SOP with GetRows:

if not rs.eof then
ar=rs.getrows
end if
rs.close
set rs=nothing
if isarray(ar) then
'you have data
else
'you don't have data
end if

HTH,
Bob Barrows
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5864
by: Harag | last post by:
Hi All I currently thinking of converting from my little knowledge of VBscript to jScript ASP. With this in mind I'm looking at my current code to see how it will convert over to Jscript. One thing I have spotted that I can't think of a way round is the ADO recordset.GetRows command.
11
3519
by: Laphan | last post by:
Hi All I'm using .getRows() with a local var array instead of doing a recursive loop so that I'm being a good ASP newvbie and closing my object i/o's (the recordset in this case) as quick as possible. My problem is that I can't seem to use this to complete good effect because the IsArray statement doesn't seem to work with a local var array that has or has not been populated with the .getRows() property.
9
3661
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
3
1997
by: Lyle Fairfield | last post by:
Sometimes we use script or code whose variable types do not correspond to the variable types of other technologies with which they interface. It's possible that our db provider may come to our rescue, both by applyling its functions and by "returning" a compatible dtat type. Here is a VBA-ADO-MS-SQL example. It uses MS-SQL functions to trim a string. (Yes, I know VBA has these functions; I am attempting to demonstrate a capability, not...
0
6280
by: si | last post by:
I'm very new to using C# in an ASP.NET application, and am used to using the ADO GetRows() method to quickly dump data into a multidimensional array in classic ASP. I am trying to work through using the ArrayList class in ASP.NET to perform a similar role, but am having difficulty in understanding and knowing how to access the data once it has been placed in an ArrayList.
1
2743
by: FrozenDude | last post by:
Help! I'm a VBA newbie and am having trouble getting the array values retrieved from getRows into a series of individual variables. Here is the query: "Select parcelID, DueDate from tablename" I have the array populated with getRows and have the number of returned rows. I need to loop through the array - somehow - and assign the tow field to variavles numParcelID and newDuedate respectively so I can use
9
35544
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows() Method of the Recordset Object. This Method varies slightly from DAO to ADO, so for purposes of this discussion, we'll be talking about DAO Recordsets. The ADO approach will be addressed in the following Tip. We'll be using a Query, consisting of 5...
2
2465
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... menuitems.js mmenu.js
3
43528
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method (GetRows()), but only as it applies to an ADO Recordset. Although there are similarities in the 2 methodologies, the ADO Method offers 2 more Optional Arguments, is a little more complex, and of course, the syntax is different in creating the...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.