By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,868 Members | 1,991 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,868 IT Pros & Developers. It's quick & easy.

how to check numeric value of field in database in asp using javascript and update

P: 3
hello
the promblem is when i want decrement the value of field in database didn't work like this:

copy=rs.fields("num_copies").value;
copy=copy-1;


then i want update the value of field (num_copies) in database

Expand|Select|Wrap|Line Numbers
  1. <%@language="javascript"%>
  2.  <!--#include file="connection.asp"-->
  3.   <%
  4.  
  5.  
  6.    RS.open("SELECT *FROM book_info where (num ="+Request.form("No_Book")+")and(title_book='"+Request.form("Book1")+"')",abCon);
  7.     if(!RS.EOF)
  8.       {
  9.  
  10.         if( RS.fields("num_copies").value >1)
  11.           {
  12.           copy=RS.fields("num_copies").value;
  13.            rent=RS.fields("Rent_book").value;
  14.            copy=copy-1;
  15.            rent=rent+1;
  16.            RS.Fields("num_copies")=copy;
  17.            RS.Fields("Rent_book")=rent;
  18.            RS.Update;
  19.           RS.Close;
  20.          abCon.close;
  21.  
  22.           }
  23.      else
  24.       {
  25.         Response.write("There is no enogh copies of this book");
  26.  
  27.        RS.close;
  28.        abCon.close;
  29.        }
  30.        }
  31.    %>
Mar 3 '13 #1

✓ answered by Rabbit

Your Copy variable is only a copy of the data on the database. It is not linked to the value in the database itself.

You will need to run an update query.

Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,370
You haven't explained what problem you're having with your code.
Mar 4 '13 #2

P: 3
hello i want know how to do it my code is wrong
Mar 4 '13 #3

P: 31
Hi Give the Clear Description that which kind of Problem you face with this code.
Mar 4 '13 #4

Rabbit
Expert Mod 10K+
P: 12,370
Your Copy variable is only a copy of the data on the database. It is not linked to the value in the database itself.

You will need to run an update query.
Mar 4 '13 #5

P: 11
Have u tried using

Expand|Select|Wrap|Line Numbers
  1. copy=rs.fields("num_copies").value;
  2. copy=CInt(copy)-1;
  3.  
Apr 6 '13 #6

Post your reply

Sign in to post your reply or Sign up for a free account.