Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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 & ""






Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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.

Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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
Reply With Quote
  #6 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.