Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

on ASP / SQL update, refresh display?

Status
Not open for further replies.

PeterMac

Programmer
Mar 9, 2001
51
CA
Hello:

I have an ASP app that walks me through a database (Access) and allows me to delete records and update them. However the way that I have my code "working" is that once I click the update button, the code behind the button works (updating the record) but the old information remains in the window until I move to another record and then back to the one that was changed, then I see the changes. Is there a way to "refresh" the current record display without having to move to the next or previous record?

I have played with resync, and with <META REFRESH> but can't seem to figure it out.

I'd be happy to post my code here if that would help...

Peter
 
is your update code in a seperate ASP file?
Then your last statement in that file should be a redirect to the 'parent'.

Eg:
BrowseFile.asp
Update.asp
Delete.asp

Last line in update.asp: response.redirect &quot;BrowseFile.asp&quot;

(this is just one way of doiing it)


br
Gerard




 
no.. the update code is right in the same paging file (so I don't have to send the data to another page)... my code follows... it all works yet may not be as clean as it could be (still learning ASP)... any pointers here would be most appreciated...

Cheers,
Peter
====================

<% @LANGUAGE = VBScript %>
<% Option Explicit
Response.Expires = 0

' ADO constants used in this page
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3

Dim objConn, objRS, strQuery
Dim strConnection, strBuild, upd_address
Dim button_next, button_last
Dim button_first, button_previous, page_number

Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
strConnection = &quot;DSN=Portal;Database=Portal;&quot;
objConn.Open strConnection
Set objRS = Server.CreateObject(&quot;ADODB.recordset&quot;)
objRS.PageSize = 1
objRS.CacheSize = 1
objRS.CursorLocation = adUseClient

objRS.Open &quot;people&quot;, strConnection, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect

Dim abspage, pagecnt
abspage = objRS.AbsolutePage
pagecnt = objRS.PageCount

If Request.ServerVariables(&quot;CONTENT_LENGTH&quot;) = 0 Then

objRS.AbsolutePage = 1

Else

Select Case Request.Form(&quot;Submit&quot;)

Case &quot;Delete&quot;

response.redirect &quot;/confirm_del.asp?people_id1=&quot; & request.form(&quot;form_people_id&quot;)

Case &quot;Update&quot;

'Build SQL command for saving record
strQuery = &quot;UPDATE people SET first_name = '&quot; & objRS(&quot;first_name&quot;)
strQuery = strQuery & &quot;', last_name = '&quot; & request.form(&quot;lname&quot;)
strQuery = strQuery & &quot;' WHERE People_id = &quot;
strQuery = strQuery & request.form(&quot;form_people_id&quot;) & &quot;;&quot;
' execute the SQL Command
Set objRS = objConn.Execute(strQuery)

Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
strConnection = &quot;DSN=Portal;Database=Portal;&quot;
objConn.Open strConnection
Set objRS = Server.CreateObject(&quot;ADODB.recordset&quot;)
objRS.PageSize = 1
objRS.CacheSize = 1
objRS.CursorLocation = adUseClient

objRS.Open &quot;people&quot;, strConnection, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect



End Select

button_first = request.form(&quot;First.x&quot;)
button_next = request.form(&quot;Next.x&quot;)
button_previous = request.form(&quot;Previous.x&quot;)
button_last = request.form(&quot;Last.x&quot;)

If button_first > 0 then
objRS.AbsolutePage = 1
End if
If button_next > 0 then
abspage = request.form(&quot;form_abspage&quot;) + 1
objRS.AbsolutePage = abspage
End if
If button_previous > 0 then
abspage = request.form(&quot;form_abspage&quot;) - 1
objRS.AbsolutePage = abspage
End if
If button_last > 0 then
abspage = pagecnt
objRS.AbsolutePage = pagecnt
End if

button_next = 0
button_last = 0
button_first = 0
button_previous = 0

End If

If Not objRS.EOF Then

Dim intRec, intValue, strValue %>

<body>
<FORM ACTION=&quot;<%= Request.ServerVariables(&quot;SCRIPT_NAME&quot;) %>&quot; METHOD=&quot;POST&quot;>
<INPUT TYPE=&quot;Hidden&quot; NAME=&quot;form_abspage&quot; VALUE=&quot;<%= abspage%>&quot;>
<INPUT TYPE=&quot;Hidden&quot; NAME=&quot;form_people_id&quot; VALUE=&quot;<%= objRS(&quot;people_id&quot;)%>&quot;>

<%= &quot;Page Counter = &quot; & abspage & &quot;<BR>&quot; %>
<%= &quot;total page count = &quot; & pagecnt & &quot;<BR>&quot; %>

<%= &quot;<BR><BR>&quot; %>
<%
Response.Write &quot;Person Id: &nbsp;&nbsp;&quot;
Response.Write trim(objRS(&quot;people_id&quot;))
Response.Write &quot;<br><br>&quot;
Response.Write &quot;First Name: &nbsp;&nbsp;&quot;
Response.Write trim(objRS(&quot;first_name&quot;))
Response.Write &quot;<br><br>&quot;
Response.Write &quot;Last Name: &nbsp;&nbsp;&quot;
%>

<Input type=&quot;text&quot; name=&quot;lname&quot; VALUE=&quot;<%= objRS(&quot;last_name&quot;)%>&quot; > <br><br>

<% ' Now showing first, next, back, last buttons.
If abspage = 1 Then %>


<INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Update&quot; Name=&quot;Submit&quot;>
<INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Delete&quot; Name=&quot;Submit&quot;>
<br>
<INPUT TYPE=image src=&quot;b_next.gif&quot;NAME=&quot;Next&quot; >
<INPUT TYPE=image src=&quot;b_last.gif&quot;NAME=&quot;Last&quot; >
<% Else
If abspage < pagecnt Then %>

<INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Update&quot; Name=&quot;Submit&quot;>
<INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Delete&quot; Name=&quot;Submit&quot;>
<br>
<INPUT TYPE=image src=&quot;b_first.gif&quot;NAME=&quot;First&quot; >
<INPUT TYPE=image src=&quot;b_prev.gif&quot;NAME=&quot;Previous&quot; >
<INPUT TYPE=image src=&quot;b_next.gif&quot;NAME=&quot;Next&quot; >
<INPUT TYPE=image src=&quot;b_last.gif&quot;NAME=&quot;Last&quot; >
<% Else %>

<INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Update&quot; Name=&quot;Submit&quot;>
<INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Delete&quot; Name=&quot;Submit&quot;>

<br>
<INPUT TYPE=image src=&quot;b_first.gif&quot;NAME=&quot;First&quot; >
<INPUT TYPE=image src=&quot;b_prev.gif&quot;NAME=&quot;Previous&quot; >


<% End If
End if

Else
Response.Write &quot;No records found!&quot;
End If

objRS.Close
Set objRS = Nothing
%>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top