0 works, "" doesn't 
Author Message
 0 works, "" doesn't

Hi - I've written some code which is used on a web page.  It works fine as
long as I set the default "there is no record" to 0 - but once I change the
default to "" (nothing/null) I get an error when the user wants to remove a
value (which in turn deletes the entire record).

Here's the error that occurs when a record gets deleted:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Record is deleted.
/lashares/profile_wishlist.asp, line 99

Here is the code sets the initial values.  If we find the record, we assign
the value to a variable which is referenced in a field,
otherwise we set it to 0. If I change this part and set the value to ""
(nothing) instead of 0, that causes the abover error message when a record
gets deleted:

<%
dim Qty
rsWishList.requery
if rsWishList.eof or rsWishList.bof then
 Qty = 0
else
 rsWishList.movefirst
 rsWishList.Find "Part_Number = " &
rsMasterInventory.Fields.Item("Part_Number").value
 if rsWishList.EOF or rsWishList.BOF then
  Qty = 0
 else
  Qty = (rsWishList.Fields.Item("Quantity").value)
 end if
end if
%>

And here is the code that finds the record and updates the value, or
adds/deletes the record.  I'll point out the line that gives the error when
a record gets deleted:

<% 'update quantities in WL table
if request("Submit") <> "" Then
dim newQty
rsMasterInventory.MoveFirst
PNarray=split(Request("PN"),",")
for i=0 to ubound(PNarray)
 rsWishList.requery
 If IsNumeric(Request("Quantity" &
rsMasterInventory.Fields.Item("Part_Number").Value)) = False then 'checking
for null here also doesn't fix it
     newQty = 0
  else
  newQty = Request("Quantity" &
rsMasterInventory.Fields.Item("Part_Number").Value)
 end if
 if rsWishList.eof or rsWishList.bof then
  'do nothing
 else
  rsWishList.movefirst
 end if
 rsWishList.Find "Part_Number = " &
rsMasterInventory.Fields.Item("Part_Number").Value '******** ERROR LINE 99
 if rsWishList.bof or rsWishList.eof then 'if there is no WL record then
  if newQty > 0 then 'if quantity is greater than 0 insert a record
     MM_Cmd.CommandText = "INSERT INTO tblRecipientWishList
(ID,Part_Number,Quantity) VALUES (" & Session("svID") & ",'" &
rsMasterInventory.Fields.Item("Part_Number").Value & "'," &
Request("Quantity" & rsMasterInventory.Fields.Item("Part_Number").Value) &
")"
    MM_Cmd.Execute
  else
   'if quantity is 0 then don't insert
  end if
 else 'if there IS a record,
  if newQty = 0 then 'and the new quantity is 0
   'delete the record
   MM_Cmd.CommandText = "DELETE FROM tblRecipientWishList WHERE ID = " &
Session("svID") & " AND PART_NUMBER = '" &
rsMasterInventory.Fields.Item("Part_Number").Value & "'"
    MM_Cmd.Execute
  else
  'if the new quantity is NOT 0, update the quantity
  rsWishList("Quantity")=newQty 'set the value to be updated in Quantity
field
  rsWishList.update 'update the record
  end if
 end if
  rsMasterInventory.movenext
next
response.redirect "profile_wishlist.asp"
end if
%>

I'm not sure if the message is saying "it's just now been deleted" or if the
loop is looking again for the record that just WAS deleted and is saying
"can't find it - that record was deleted".

I would appreciate someone's keen eye on this.... I've been staring at it
all day and my brain hurts.

Thanks much for any ideas.

-R



Sun, 17 Oct 2004 02:24:50 GMT  
 0 works, "" doesn't
I'm not sure of your question. Anyway "" is neither null nor nothing. If you
use db, try null instead of "".
One more comment. 0 is a number and "" is a string. You had better not use
the two on the same field even if it is allowed.

--
Han Pohwan
Seoul, Korea, MS Asia MVP

Quote:
> Hi - I've written some code which is used on a web page.  It works fine as
> long as I set the default "there is no record" to 0 - but once I change
the
> default to "" (nothing/null) I get an error when the user wants to remove
a
> value (which in turn deletes the entire record).

> Here's the error that occurs when a record gets deleted:

> Microsoft OLE DB Provider for ODBC Drivers error '80004005'
> [Microsoft][ODBC Microsoft Access Driver] Record is deleted.
> /lashares/profile_wishlist.asp, line 99

> Here is the code sets the initial values.  If we find the record, we
assign
> the value to a variable which is referenced in a field,
> otherwise we set it to 0. If I change this part and set the value to ""
> (nothing) instead of 0, that causes the abover error message when a record
> gets deleted:

> <%
> dim Qty
> rsWishList.requery
> if rsWishList.eof or rsWishList.bof then
>  Qty = 0
> else
>  rsWishList.movefirst
>  rsWishList.Find "Part_Number = " &
> rsMasterInventory.Fields.Item("Part_Number").value
>  if rsWishList.EOF or rsWishList.BOF then
>   Qty = 0
>  else
>   Qty = (rsWishList.Fields.Item("Quantity").value)
>  end if
> end if
> %>

> And here is the code that finds the record and updates the value, or
> adds/deletes the record.  I'll point out the line that gives the error
when
> a record gets deleted:

> <% 'update quantities in WL table
> if request("Submit") <> "" Then
> dim newQty
> rsMasterInventory.MoveFirst
> PNarray=split(Request("PN"),",")
> for i=0 to ubound(PNarray)
>  rsWishList.requery
>  If IsNumeric(Request("Quantity" &
> rsMasterInventory.Fields.Item("Part_Number").Value)) = False then
'checking
> for null here also doesn't fix it
>      newQty = 0
>   else
>   newQty = Request("Quantity" &
> rsMasterInventory.Fields.Item("Part_Number").Value)
>  end if
>  if rsWishList.eof or rsWishList.bof then
>   'do nothing
>  else
>   rsWishList.movefirst
>  end if
>  rsWishList.Find "Part_Number = " &
> rsMasterInventory.Fields.Item("Part_Number").Value '******** ERROR LINE 99
>  if rsWishList.bof or rsWishList.eof then 'if there is no WL record then
>   if newQty > 0 then 'if quantity is greater than 0 insert a record
>      MM_Cmd.CommandText = "INSERT INTO tblRecipientWishList
> (ID,Part_Number,Quantity) VALUES (" & Session("svID") & ",'" &
> rsMasterInventory.Fields.Item("Part_Number").Value & "'," &
> Request("Quantity" & rsMasterInventory.Fields.Item("Part_Number").Value) &
> ")"
>     MM_Cmd.Execute
>   else
>    'if quantity is 0 then don't insert
>   end if
>  else 'if there IS a record,
>   if newQty = 0 then 'and the new quantity is 0
>    'delete the record
>    MM_Cmd.CommandText = "DELETE FROM tblRecipientWishList WHERE ID = " &
> Session("svID") & " AND PART_NUMBER = '" &
> rsMasterInventory.Fields.Item("Part_Number").Value & "'"
>     MM_Cmd.Execute
>   else
>   'if the new quantity is NOT 0, update the quantity
>   rsWishList("Quantity")=newQty 'set the value to be updated in Quantity
> field
>   rsWishList.update 'update the record
>   end if
>  end if
>   rsMasterInventory.movenext
> next
> response.redirect "profile_wishlist.asp"
> end if
> %>

> I'm not sure if the message is saying "it's just now been deleted" or if
the
> loop is looking again for the record that just WAS deleted and is saying
> "can't find it - that record was deleted".

> I would appreciate someone's keen eye on this.... I've been staring at it
> all day and my brain hurts.

> Thanks much for any ideas.

> -R



Mon, 22 Nov 2004 16:00:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SendKeys "{tab}" doesn't work

2. href="javascript:parent.window.close() doesn't work

3. "Replace"-Message doesn't prompt

4. "Replace"-Message doesn't prompt

5. autoscrollposition doesn't "stick"

6. Why CreateObject("MyDLLName.MyClsName","MTSServerName") doesn't work?

7. "Winnt://domain" won't work

8. vbajet32.dll isn't "working"

9. AppActivate "WordPerfect" won't work

10. response.write "\"" doesn't work.....

11. Inheriting from "UserControl" doesn't allow for persiting "Text"

12. Control w/"&" Doesn't Show As "Access" Key

 

 
Powered by phpBB® Forum Software