There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot computer connection crash css dell drive driver drivers email error ethernet excel explorer firefox firefox 3 freeze hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook express password printer problem problems router security slow software sound startup trojan usb virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
ASP - Cannot Retrieve record from a 'single - record' recordset


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
trmnorm's Avatar
Junior Member with 4 posts.
 
Join Date: Oct 2004
Experience: Advanced
29-Oct-2004, 10:20 AM #1
ASP - Cannot Retrieve record from a 'single - record' recordset
ASP using an access db. I have create a recordset that will return a single record and I'm trying to retrieve that record. When I try to get the record it won't retrieve that value. This is only happening when it is one record in the recordset. The recordset is not at BOF or EOF. Do anyone have any solutions or other alternatives. Need help ASAP, I have been working on this for several days. Below is the code:

Set rsHotFix2 = Server.CreateObject("ADODB.Recordset")
rsHotFix2.ActiveConnection = MM_AMT_DTS_STRING
rsHotFix2.Source = "SELECT Max([CID]) AS LastCID, SID FROM TCO_Contractors Group By LastCID, SID HAVING (TCO_Contractors.SID= "&rsHirerachy__MMColParam&")"
rsHotFix2.CursorType = 0
rsHotFix2.CursorLocation = 2
rsHotFix2.LockType = 1
rsHotFix2.Open()

if rsHotFix2.bof and rsHotFix2.eof then

response.write "Recordset Is Empty"
else
response.write "Recordset Is Not Empty"
response.write rsHotFix2.Fields(0) & "<BR>"
response.write rsHotFix2.Fields("LastCID") & "<BR>"
response.write rsHotFix2.Fields.Item("LastCID") & "<BR>"
response.write rsHotFix2("LastCID") & "<BR>"


end if


This is what's display on the page
Recordset Is Not Empty



Notice it does display the CID value.
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
29-Oct-2004, 10:36 AM #2
response.write "Recordset Is Not Empty"
response.write rsHotFix2.Fields(0) & "<BR>"
response.write rsHotFix2.Fields("LastCID") & "<BR>"
response.write rsHotFix2.Fields.Item("LastCID") & "<BR>"
response.write rsHotFix2("LastCID") & "<BR>"


Why are you writing out the same thing in 4 different lines of code? Your recordset is only supposed to return the highest numbered CID from the table matching one criteria of SID HAVING (TCO_Contractors.SID= "&rsHirerachy__MMColParam&")" Can you put in a fixed value into your criteria for a known good value in the table or recordset and see if it returns the correct CID then?
__________________
**Disclaimer** Anything below this line ^ is part of my signature for those that may be confused

Sadly, there are no integers on this scale, so your gangly adolescent attempt to be clever has proved futile....Dieter

I have the right "NOT" to be tolerant of others because they are different, weird, or tick me off.....Parody of Andy Rooney

There are no stupid questions, but there are a LOT of inquisitive idiots.
trmnorm's Avatar
Junior Member with 4 posts.
 
Join Date: Oct 2004
Experience: Advanced
29-Oct-2004, 11:01 AM #3
Thanks Rockn for the replay...

I'm writing it out four different ways, because neither way returns me a value when I know the value should be CID=302. None of these ways of retrieving the value are working.

I have used a known SID=3002 that's not making a difference it's still returns a recordset, but it won't let me retrieve the value...

I'm only having this problem when it's a single record in the recordset. I have never seen this happen before.

trmnorm
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
29-Oct-2004, 11:09 AM #4
Is this supposed to be Max([CID]) or Max([SID])
trmnorm's Avatar
Junior Member with 4 posts.
 
Join Date: Oct 2004
Experience: Advanced
29-Oct-2004, 11:15 AM #5
It's Max([CID])

query return CID = 302
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
29-Oct-2004, 02:26 PM #6
Have you tried a different cursor type? Has it ever worked. If there is only one record in the table there BOF and EOF are going to be the same. Try:

If Not rsHotFix2.eof then
response.write "Recordset Is Empty"
else
response.write "Recordset Is Not Empty"
response.write rsHotFix2.Fields(0) & "<BR>"
response.write rsHotFix2.Fields("LastCID") & "<BR>"
response.write rsHotFix2.Fields.Item("LastCID") & "<BR>"
response.write rsHotFix2("LastCID") & "<BR>"
__________________
**Disclaimer** Anything below this line ^ is part of my signature for those that may be confused

Sadly, there are no integers on this scale, so your gangly adolescent attempt to be clever has proved futile....Dieter

I have the right "NOT" to be tolerant of others because they are different, weird, or tick me off.....Parody of Andy Rooney

There are no stupid questions, but there are a LOT of inquisitive idiots.
trmnorm's Avatar
Junior Member with 4 posts.
 
Join Date: Oct 2004
Experience: Advanced
29-Oct-2004, 03:06 PM #7
Once again thank you so much for your timely response and help.

I have fix the problem by finding another way to skin the cat. And yes I did try changing the cursortype as well as the locktype.

So here is the fix, for anyone else who my experience this problem:

I just combine the select statement and the insert statement into a subquery and executed it. And it worked perfectly.

If flagOneContractor = "yes" Then

'response.write "Yes One Record"

cmdIns.CommandText = "INSERT INTO SurveyAreaSupported ( SID, CID, AreaSupported ) SELECT TCO_Contractors.SID, TCO_Contractors.CID, '" & rsGetAS("AreaSupported") & "' AS Expr FROM TCO_Contractors WHERE (((TCO_Contractors.SID)="&pkex&"))"

Else

'response.write "More than one Record"
cmdIns.CommandText = "INSERT INTO SurveyAreaSupported (SID, CID, AreaSupported) VALUES ("&pkex&"," & rsGetNames2("CID") & ",'" & rsGetAS("AreaSupported") & "')"

End If
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:35 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.