473,320 Members | 2,004 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,320 software developers and data experts.

updating record errer ?

Fary4u
273 100+
Hi

i've got product ID Auto number in MS Access but i can't update or insert 2 values into the same database field

Expand|Select|Wrap|Line Numbers
  1. <HTML><HEAD><TITLE>fds</TITLE></HEAD>
  2. <BODY >
  3. <% 
  4. Dim objrs,objConn
  5. Dim xx, yy, hh, ww, tkid
  6.  
  7. tkid = Trim(Request.QueryString("ID"))
  8. xx   = Trim(Request.QueryString("x2"))
  9. yy   = Trim(Request.QueryString("y2"))
  10.  
  11.  
  12. Set objConn = Server.CreateObject("ADODB.Connection")
  13. objConn.open ConString
  14. set objrs = server.createObject("ADODB.RecordSet")
  15. ' these 3 values should not be in the database.
  16. objrs.open "select dx, dy from pix1 where ID = " & tkid & " and dx = " & xx & " and dy =" & yy &";",objConn,Adopendynamic,Adlockoptimistic
  17. if objrs.eof then
  18.  
  19.     objrs.Addnew
  20. 'tkid already into the database only these 2 value need to add ?
  21.                objrs("dx")=xx
  22.                objrs("dy")=yy
  23.                objrs.update
  24.  
  25.            response.write" New Record save in the Database"
  26. else
  27.            response.write" This Record already in a Database"
  28. end if
  29.  
  30. objrs.close
  31. set objrs= Nothing
  32. objConn.Close
  33. set objConn = Nothing
  34. %>
  35. </BODY></HTML>
  36.  
  37.  
  38. any body know where is the problem or any body can solve this problem ?
  39.  
Oct 1 '07 #1
3 1194
markrawlingson
346 Expert 100+
More than likely it's a data type mismatch issue. Is that the error you're getting because I can definately see that happening.

You are pulling xx and yy down from the querystring and then inserting those values into the database.

When you pull a value down from the querystring, it is a STRING data type - so if the column in your table has an integer value, for instance, and you try to put unmodified information from the querystring into it - it will throw a data type mismatch error even though the data you're pulling from the querystring might be a number, it's still considered a string by ASP at this point. Instead of being looked at as, say, 13 - it is being looked at as "13"

I recommend wrapping CINT around the following code to force it to become a number..

tkid = CINT(Trim(Request.QueryString("ID")))
xx = CINT(Trim(Request.QueryString("x2")))
yy = CINT(Trim(Request.QueryString("y2")))

Just remember that CINT will drop any decimal places your number might have.
Oct 1 '07 #2
Fary4u
273 100+
Thanks for your kindly reply

i think so your rite that's might be this problem i'm gonna take a look 2marrow in more detail,

following my inquiry, my SQL Statement is rite ? coz i need to check 3 value compression into the database & then update the xx & yy value only with selected product ID ( tkid )

Expand|Select|Wrap|Line Numbers
  1. objrs.open "select dx, dy from pix1 where ID = " & tkid & " and dx = " & xx & " and dy =" & yy &";",objConn,Adopendynamic,Adlockoptimistic 
Oct 1 '07 #3
jhardman
3,406 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. objrs.open "select dx, dy from pix1 where ID = " & tkid & " and dx = " & xx & " and dy =" & yy &";",objConn,Adopendynamic,Adlockoptimistic 
you have written it as if expecting that ID, dx, and dy are all numeric values. If that is the case, then yes it all looks good. If any of these are supposed to be strings or dates or any other format, then it will need to be changed.

Jared
Oct 1 '07 #4

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

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
1
by: Chris Jackson | last post by:
I'm a novice Access user and am not sure how to solve the following problem. Any help with the following would be greatly appreciated! I have two tables with identical structures, the first holds...
2
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the...
3
by: MLH | last post by:
I have a form, bound to a query. Its RecordSource property is a query named frmEnterLienAmounts. The form has a few bound controls and some unbound controls. The unbound controls are calculated...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
4
by: Winshent | last post by:
I am having problems with adding items to my shopping cart. The problem occures when adding items that already exists in the cart. When a user adds to cart, they are automatically redirected to...
5
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
4
by: aaronyoung | last post by:
I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query. My On Current event to update the "Record X of...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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.