Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
|
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 January 10th, 2005, 07:52 PM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trouble with getting the correct data after UPDATE

Hello,

I'm using Access DB and what I want to do is the following with an ASP:
1-Display the content of a table named "test" (no problem)
2-Update the record where a certain field "FileDesc" is equal to "A", just make it "X" instead.
3-Re-Display the content of "test".

I want to see, on the same ASP page, the content of the table before and after the update.

I tried to do the Update with a recordset and a command but no way. The update is well performed but what I see on the screen is either 2 times the data before the Update or 2 times the data after the update.

Here is the code and thanks for your replies.

<%
dim Connect, objRS, objRS1, objConn, objRSU, strSQL
    Connect= "DSN=TC-Sin-Av-Dap;DRIVER={Microsoft Access Driver (*.mdb)}"
    Set objRS = Server.CreateObject("ADODB.Recordset")
    Set objRS1 = Server.CreateObject("ADODB.Recordset")
    Set objRSU = Server.CreateObject("ADODB.Recordset")
    objRS.Open "test", Connect, adCmdTable
Response.Write "Initial data <br>"
While NOT objRS.EOF
    'Display the initial content
    Response.Write objRS.Fields("FileID").Value & ", " & objRS.Fields("FileRefTC").Value & ", " & objRS.Fields("FileDesc").Value & "<br>"
    objRS.MoveNext
Wend
Response.write "<p></p>"
objRS.Close
set objRS = Nothing
'Now change all FileDesc=A to XX
strSQL = "UPDATE test SET FileDesc = 'XX' WHERE FileDesc = 'A'"
objRSU.Open strSQL, Connect, adCmdText

Response.Write "Updated data <br>"
'Display the content after the changes
objRS1.Open "test", Connect, adCmdTable
While NOT objRS1.EOF
    Response.Write objRS1(0) & ", " & objRS1(1) & ", " & objRS1(3) & "<br>"
    objRS1.MoveNext
Wend
objRS1.Close
set objRS1 = Nothing
%>
The result page is:
Initial data
1, 030528-1, A
2, 030528-2, A
3, 50103-1, A
4, 50103-1, B
5, 50104-2, B
6, 50104-2, B
7, 50105-1, C
8, 50105-1, C


Updated data
1, 030528-1, A
2, 030528-2, A
3, 50103-1, A
4, 50103-1, B
5, 50104-2, B
6, 50104-2, B
7, 50105-1, C
8, 50105-1, C

The changes are not displayed while in the DB they are done.

Thanks for your help.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Correct my xslt for data substitution asap XSLT 0 July 29th, 2006 03:42 PM
Trouble with getting the correct data after UPDATE Hammad Classic ASP Databases 3 January 8th, 2005 09:57 AM
Date trouble using Dreamweaver Update Dirosky Dreamweaver (all versions) 2 January 8th, 2004 09:06 AM





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