Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 15th, 2003, 01:49 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , .
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to Update

Hi All,

I have created two ASP files(Insert.asp and Update.asp). Let me first explain my setup. I have an Access database with an "AutoNumber" field called "ReferenceNumber." So each time I INSERT a record, the ReferenceNumber will increment by one.

Now, with my Insert.asp page, I insert a record into the Access database. Once I have done that, i want to use the Update.asp page to update that record I have just inserted.

Here is the problem. Every time I do an update to a particular record, a new record is added to the database instead of updating that particular record. Hence, a new ReferenceNumber(AutoNumber) is generated. Below are my codes of the update.asp file. PLEASE HELP!!! I have checked my codes over and over, and they seems right. I just don't know why it cause to generate a new record. It is driving me crazy! Your helps are GREATLY appreciated!!! THANK YOU!!!


incumbentname=Request.form("incumbentname")
analystname=Request.form("analystname")
rnumber=request.form("referencenumber")

Set conn = Server.CreateObject("ADODB.Connection")
cnpath="DBQ=" & server.mappath("classifications_studies.mdb")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath

SQLstmt = "UPDATE classificationmain SET "
SQLstmt = SQLstmt & "positionnumber='" & positionnumber & "',"
SQLstmt = SQLstmt & "incumbentname='" & incumbent & "',"
SQLStmt = SQLStmt & " where referencenumber= " & rnumber & ""






 
Old February 4th, 2004, 05:41 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Can you post your complete code..? SQL Statement looks fine
 
Old February 17th, 2004, 07:06 AM
Authorized User
 
Join Date: Dec 2003
Location: Nairobi, N/A, Kenya.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to MAMBONO
Default

The problem seems to be with your update statements. It might help with you posting the whole code.

 
Old February 17th, 2004, 10:47 AM
Authorized User
 
Join Date: Dec 2003
Location: Middletown, CT, USA.
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Enter a response.write (referencenumber) into your update asp page. This will display the value of referencenumber that is being passed to the update page. I think that referencenumber from the request form is passing a null value. This is because incrementing is done at the table level, not on the insert page. Accordingly, the update page is posting to the first record where referencenumber =" " If you post both pages of code I can verify my suspicion

John
 
Old March 18th, 2004, 04:28 AM
Authorized User
 
Join Date: Mar 2004
Location: Amman, , Jordan.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliasp Send a message via Yahoo to aliasp
Default

Hi There,
to do that proberly you must at first Consider the fields that will be chang are(positionnumber,incumbentname), and the field that must be fixed is (referencenumber)in order to determine which the recordset need to update.

then write the code below :

conn.execute = "UPDATE classificationmain SET " & _
& SQLstmt = SQLstmt & "positionnumber='" & positionnumber & "'," & _
& SQLstmt = SQLstmt & "incumbentname='" & incumbent & "'" & _
& SQLStmt = SQLStmt & " where referencenumber= " & rnumber & ""

Note the second code line (incumbentname) it must be with out (,).

reg,

ASP MAN


ali
 
Old March 18th, 2004, 05:23 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

At least response.write the ACTUAL SQL that will be excuted. Also consider moving to an OleDb connection string, they are much more reliable than the ODBC driver.

--

Joe




Similar Threads
Thread Thread Starter Forum Replies Last Post
Update unable to find TableMapping ahager C# 5 June 23rd, 2007 06:20 AM
Unable to update ms access's table hunzian78@yahoo.com ASP.NET 2.0 Professional 0 September 18th, 2006 02:41 AM
unable to update MySQL database with ASP don baroo Classic ASP Databases 7 November 22nd, 2004 01:22 PM
Unable to update database on server senthilpr_in Access ASP 1 September 23rd, 2003 11:43 PM
Unable to update database on server senthilpr_in Classic ASP Databases 0 September 8th, 2003 04:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.