Get Bad Data from a Recordset Call

B

belacyrf

Here's the code:
-------------------------------------------------------------------
accessID = request("accessID")

strSQL = "SELECT * From PendingAccRequests Where AccessID = "&accessID

'Create the Recordset object and run SQL statement
Set accRS = Server.CreateObject ("ADODB.Recordset")
accRS.Open strSQL, objConn

If request("confirm") = "yes" then
strSQL = "Select * From AccessMaster Where RequestID = "&accessID
'Create the Recordset object and run SQL statement
Set masterRS = Server.CreateObject ("ADODB.Recordset")
masterRS.CursorLocation = adUseClient
masterRS.Open strSQL, objConn,, adLockOptimistic

masterRS.AddNew
masterRS("PropownID") = accRS("Bld_Owner_ID")
masterRS("FileName") = accRS("PROPOWN_Name")
masterRS("Multiagreement") = False
masterRS("OpenDate") = Date()
masterRS("requestID") = accessID
masterRS.Update

strSQL = "Select * From Access Where MasterID =
"&masterRS("MasterID")
'Create the Recordset object and run SQL statement
Set newRS = Server.CreateObject ("ADODB.Recordset")
newRS.CursorLocation = adUseClient
newRS.Open strSQL, objConn,, adLockOptimistic

newRS.AddNew
newRS("Prop_Owner_ID") = accRS("Bld_Owner_ID")
newRS("Acct_Mgr") = accRS("Assigned")
newRS("Status") = "OPEN"
newRS("Source_Date") = accRS("AccessDate")
If Not IsNull(accRS("ProjID")) then
newRS("Source_Info") = "SALES REQUEST"
Else
newRS("Source_Info") = "CONSTRUCTION"
End If
newRS("File_Received") = Date()
newRS("MasterID") = masterRS("MasterID")
newRS.Update


If Not IsNull(accRS("ProjID")) then

strSQL = "Insert Into AccessBldg (AccessID, BidID) "&_
"Select "&newRS("AccessID")&", BID_ID from ConstructionBldg Where
ProjectID = "&accRS("ProjID"))
objConn.Execute(strSQL)

strSQL = "Update Building Set Bld_Access_ID =
"&masterRS("MasterID")&" Where Bld_Address_ID in "&_
"(Select Bid_ID From ConstructionBldg Where ProjectID =
"&accRS("ProjID")) &")"
objConn.Execute(strSQL)
Else
strSQL = "Select * From AccessBldg Where AccessID =
"&accIDRS("AccessID")
'Create the Recordset object and run SQL statement
Set accBldRS = Server.CreateObject ("ADODB.Recordset")
accBldRS.CursorLocation = adUseClient
accBldRS.Open strSQL, objConn,, adLockOptimistic

accBldRS.AddNew
accBldRS("AccessID") = accIDRS("AccessID")
accBldRS("BidID") = accRS("BidID")
accBldRS("suite") = accRS("Suite")
accBldRS.Update

strSQL = "Select * From Building Where Bld_Address_ID =
"&accRS("BidID")
'Create the Recordset object and run SQL statement
Set bldRS = Server.CreateObject ("ADODB.Recordset")
bldRS.CursorLocation = adUseClient
bldRS.Open strSQL, objConn,, adLockOptimistic
bldRS("Bld_Access_ID") = masterRS("MasterID")
bldRS.Update
End If
strSQL = "Update AccessRequest Set Completed = 1 Where AccessID =
"&AccessID
objConn.Execute(strSQL)

Response.Redirect("handler.asp?id="&newRS("AccessID") )

End If
---------------------------------------------------------------

Now you'll notice I'm updating and pulling from multiple recordsets.
Here's the problem.
PendingAccRequests is a View, and when I run the SQL query (Where
AccessID = "&accessID), I get good data.
So I plug it into accRS.
Now in that row there is a column called projID... it has the number
477 in it.
But Anytime I try and call that field (accRS("ProjID")) I get nothing.
It Will Not return my 477. This is the problem

Just FYI.
When I call newRS("AccessID") which is the ident key of the record I'm
adding, I also get nothing.
When I call accRS("Assigned") which is filled with the number 47, I
get nothing.
When I call masterRS("MasterID") which is another ident field of a
recordset I'm adding. I get the wrong number. I do not know where the
number is coming from.

Can anyone tell me what could be wrong???

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top