473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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.

5 1873
Rabbit
12,516 Expert Mod 8TB
You haven't explained what problem you're having with your code.
Mar 4 '13 #2
dosa
3
hello i want know how to do it my code is wrong
Mar 4 '13 #3
Hi Give the Clear Description that which kind of Problem you face with this code.
Mar 4 '13 #4
Rabbit
12,516 Expert Mod 8TB
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
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

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

Similar topics

7
by: NewbieJon | last post by:
I am attempting to send the variable "sComputerName" from my ActiveX script to "GetInfo.asp" using javascript. (Having been advised this is the way to get my ActiveX variable into my ASP script) ...
10
by: Roger Withnell | last post by:
I'm using ASP, VBScript and SQL Server. I'm also using UTF-8 character set and so my codepage is 65001 and SQL Server datatype nvarchar. I can insert unicode characters correctly into the...
2
by: rockdale | last post by:
Hi, All: I have a datagrid that embedded 3 textbox using TemplateColumn. When the user key in value in the first textbox, I need to check to see if this value is between the the values in other...
17
by: kartheek | last post by:
hi friends, can any one out here help me by giving me the code to connect to an MSACCESS database using javascript.
5
by: SKS | last post by:
hi all i would like to know how to restrict user from entering numeric value ina textbox..using C# if user try to enter text it shouldnt be allowed.. i tried errror provider.. but it doesnt met...
4
by: Mahbub Hasan | last post by:
There r 3 checkbox . .. first check box value = 2 , second check box value = 4 , third check box value = 6 . now if i check 1st one it will send 2 to the database field, if check the first and...
5
by: lintolawrance | last post by:
hi friends, can any one out here help me by giving me the code to connect to an SOL database using javascript.
0
by: tarkuser | last post by:
Hai... I have problem in storing values from flash to database and to select data from a database using Javascript. First i get details of a student through flash and then sotre it to database...
0
by: baburmm | last post by:
Hai, I want to get the footer textbox value in gridview using javascript any one help me Regards, Babu.K
7
by: saadkhan | last post by:
Is there any way to create xml file and save it in SQL Server database all using javascript? I have no security issues for the purpose i need to do it. Though if anyone could give me some better idea...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.