Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 7th, 2005, 10:28 AM
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 have trouble doing the following with ASP. I'm using Access DB and what I want to do is the following:
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.
3Re-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.

Can someone help please?
 
Old January 7th, 2005, 11:16 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

It would be better if you could post the code ... so that somebody could check and revert.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old January 8th, 2005, 12:30 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshbabu Send a message via Yahoo to sureshbabu
Default

Hi,

you can do as folows..

If Request.querystring("mode") = "update" Then
     write update code here.
End If


write code to display records...
suppose if you have the link to update then use like this..
<a href="samePage.asp?mode=update">update</a>

It will post you to the same page with mode ="update" Then your update will code will be executed and agin it will display latest records..

But your update code should be at the top.It is must after that only display code should be there in that page.


Thans
Suresh
 
Old January 8th, 2005, 09:57 AM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry guys, 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 Access ASP 0 January 10th, 2005 07:52 PM
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.