Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Update problem


Message #1 by lodris@m... on Fri, 25 May 2001 16:08:14
Does anyone know why this isnt working i want to continually set the 

balance field in the database to newbal everytime i execute this statement

The components all work fine individually its just when i check to see if 

balance is greater than sharecost then it redirects me no matter what and 

doesnt update the balance field.

Thnaks 

Leigh



sharecost = (pricevariable * qleigh)

newbal = (balancevarialbe - sharecost)





if balance > sharecost then

set rs2=conn.execute("UPDATE sharesuser SET balance = " & newbal & " where 

UserName = '" & Session("strLogin") & "' ") 

else response.redirect "leigh6.html"

end if 
Message #2 by "Imar Spaanjaars" <Imar@S...> on Fri, 25 May 2001 19:59:38
In the code you gave, balance does not have a value (or at least it's not 

defined in the code below).



Make sure that you give balance a value before comparing it with 

sharecost. You may also need to cast your data to the proper type, for 

example with CLng(balance) before you compare.



Hope this helps,



Imar





> Does anyone know why this isnt working i want to continually set the 

> balance field in the database to newbal everytime i execute this 

statement

> The components all work fine individually its just when i check to see 

if 

> balance is greater than sharecost then it redirects me no matter what 

and 

> doesnt update the balance field.

> Thnaks 

> Leigh

> 

> sharecost = (pricevariable * qleigh)

> newbal = (balancevarialbe - sharecost)

> 

> 

> if balance > sharecost then

> set rs2=conn.execute("UPDATE sharesuser SET balance = " & newbal & " 

where 

> UserName = '" & Session("strLogin") & "' ") 

> else response.redirect "leigh6.html"

Message #3 by "Dallas Martin" <dmartin@z...> on Fri, 25 May 2001 11:43:55 -0400
Force both values to either currency or doubles

using the CCUR() or CDBL() functions



Then try the comparison.



sharecost = CCUR((pricevariable * qleigh))

 newbal = CCUR((balancevarialbe - sharecost))



Just make sure that the parameters are not NULL or empty strings



Dallas







----- Original Message -----

From: <lodris@m...>

To: "ASP Databases" <asp_databases@p...>

Sent: Friday, May 25, 2001 4:08 PM

Subject: [asp_databases] Update problem





> Does anyone know why this isnt working i want to continually set the

> balance field in the database to newbal everytime i execute this statement

> The components all work fine individually its just when i check to see if

> balance is greater than sharecost then it redirects me no matter what and

> doesnt update the balance field.

> Thnaks

> Leigh

>

> sharecost = (pricevariable * qleigh)

> newbal = (balancevarialbe - sharecost)

>

>

> if balance > sharecost then

> set rs2=conn.execute("UPDATE sharesuser SET balance = " & newbal & " where

> UserName = '" & Session("strLogin") & "' ")

> else response.redirect "leigh6.html"

> end if



Message #4 by Greg Griffiths <griffiths@x...> on Fri, 25 May 2001 19:13:48 +0100
have you tried :



1. Printing your variables at this point to see what values they have ?

2. Converting them all to Number using CInt to be sure that they are all

numbers ?



At 16:08 25/05/01 +0000, you wrote:

>Does anyone know why this isnt working i want to continually set the

>balance field in the database to newbal everytime i execute this statement

>The components all work fine individually its just when i check to see if

>balance is greater than sharecost then it redirects me no matter what and

>doesnt update the balance field.

>Thnaks

>Leigh

>

>sharecost =3D (pricevariable * qleigh)

>newbal =3D (balancevarialbe - sharecost)

>

>

>if balance > sharecost then

>set rs2=3Dconn.execute("UPDATE sharesuser SET balance =3D " & newbal & "

 where

>UserName =3D '" & Session("strLogin") & "' ")

>else response.redirect "leigh6.html"

>end if




  Return to Index