|
-
Aug 18th, 2006, 07:01 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Quick question regarding empty recordsets
hi all
I have a recordset that sometimes will pull no data due to changes made to the database tables throughout the useage of the program. My question is this, what is the syntax to handle recordsets when they come up with no info?
i have tried things like this:
VB Code:
If rs("")<>"" then do something
and
VB Code:
IF isNull(rs("")) then do something
how would i word the part concerning the rs on order to satisfy the IF statement?
With both examples i get a
"Item cannot be found in the collection corresponding to the requested name or ordinal."
thanks alot
tibor
-
Aug 18th, 2006, 07:04 AM
#2
Hyperactive Member
Re: Quick question regarding empty recordsets
VB Code:
If rs.RecordCount = 0 Then
' No Rows Returned '
End If
-
Aug 18th, 2006, 07:07 AM
#3
Hyperactive Member
Re: Quick question regarding empty recordsets
You would need a valid field name between the "".
VB Code:
If rs.Fields("FieldName").Value & "" = "" Then
' All this really tells you is that "FieldName" is Null or Blank..... '
' Record Count is One Way '
End If
VB Code:
If rs.Eof = True Then
' Also means no records (right after the select) '
End If
-
Aug 18th, 2006, 07:14 AM
#4
Thread Starter
Addicted Member
Re: Quick question regarding empty recordsets
ok great. thanks so much!
the Rs.EOF took care of it. The rowcount always came back as -1. Why would it ever come back as a neg?
tibor
-
Aug 18th, 2006, 07:18 AM
#5
Re: Quick question regarding empty recordsets
 Originally Posted by tibor
the Rs.EOF took care of it. The rowcount always came back as -1. Why would it ever come back as a neg?
That is a built in "featue" of an ado serverside recordset and when the CursorType is adOpenForwardonly or adOpenDynamic.
Use either adOpenKeyset or adOpenStatic as the CursorType for server side cursors or use a client side cursor. Client side cursors use only adOpenStatic for CursorTypes regardless of which CursorType you select.
-
Aug 18th, 2006, 07:51 AM
#6
Thread Starter
Addicted Member
Re: [RESOLVED] Quick question regarding empty recordsets
Ok, sweet. thanks. Now its something I know.. haha.
tibor
-
Aug 18th, 2006, 09:44 AM
#7
Re: [RESOLVED] Quick question regarding empty recordsets
If you set rs.CursorLocation = adUseClient (before you open the recordset) you'll get back valid rowcounts.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|