Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Problems with a Select after an Insert


Message #1 by "p" <paul@m...> on Tue, 18 Dec 2001 01:32:59
I am having trouble getting most recent record from a select statement on 

the same page I am doing an Insert.  Ex. it's a simple shopping cart where 

items are added (inserted) at top of the page and items are displayed 

(select) at the bottom.  While the insert has actually taken place in the 

database, I must refresh my page to get the Select to grab most recent 

record.



Any help, is it a configuration issue, driver issue or is it the way I am 

doing my queries.



Oh yea, Access 97/ASP/IIS 4.0 is what I am running.



Thanks in advance,

PJ
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 18 Dec 2001 12:43:33 +1100
Are you expiring your pages? and/or preventing caching



<%

Sub SetHeaders( _

    )



    Response.ExpiresAbsolute = #1/1/1980#

    Response.CacheControl = "private"

    Response.AddHeaders "pragma", "no-cache"



End Sub

'

Call SetHeaders()

%>



Alternatively, how are you creating the 2nd recordset? Using a SQL select

statement? or are you reusing a recordset that you used to insert the data

in the first place?



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "p" <paul@m...>

Subject: [asp_databases] Problems with a Select after an Insert





: I am having trouble getting most recent record from a select statement on

: the same page I am doing an Insert.  Ex. it's a simple shopping cart where

: items are added (inserted) at top of the page and items are displayed

: (select) at the bottom.  While the insert has actually taken place in the

: database, I must refresh my page to get the Select to grab most recent

: record.

:

: Any help, is it a configuration issue, driver issue or is it the way I am

: doing my queries.

:

: Oh yea, Access 97/ASP/IIS 4.0 is what I am running.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Message #3 by "p" <paul@m...> on Tue, 18 Dec 2001 02:01:25
I've tried expiring the cache and I am using a completely new recordset.  



> Are you expiring your pages? and/or preventing caching

> 

> <%

> Sub SetHeaders( _

>     )

> 

>     Response.ExpiresAbsolute = #1/1/1980#

>     Response.CacheControl = "private"

>     Response.AddHeaders "pragma", "no-cache"

> 

> End Sub

> '

> Call SetHeaders()

> %>

> 

> Alternatively, how are you creating the 2nd recordset? Using a SQL select

> statement? or are you reusing a recordset that you used to insert the 

data

> in the first place?

> 

> Cheers

> Ken

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> From: "p" <paul@m...>

> Subject: [asp_databases] Problems with a Select after an Insert

> 

> 

> : I am having trouble getting most recent record from a select statement 

on

> : the same page I am doing an Insert.  Ex. it's a simple shopping cart 

where

> : items are added (inserted) at top of the page and items are displayed

> : (select) at the bottom.  While the insert has actually taken place in 

the

> : database, I must refresh my page to get the Select to grab most recent

> : record.

> :

> : Any help, is it a configuration issue, driver issue or is it the way I 

am

> : doing my queries.

> :

> : Oh yea, Access 97/ASP/IIS 4.0 is what I am running.

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

Message #4 by "Ken Schaefer" <ken@a...> on Tue, 18 Dec 2001 15:23:58 +1100
Can you provide some code please?



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "p" <paul@m...>

Subject: [asp_databases] Re: Problems with a Select after an Insert





: I've tried expiring the cache and I am using a completely new recordset.

:

: > Are you expiring your pages? and/or preventing caching

: >

: > <%

: > Sub SetHeaders( _

: >     )

: >

: >     Response.ExpiresAbsolute = #1/1/1980#

: >     Response.CacheControl = "private"

: >     Response.AddHeaders "pragma", "no-cache"

: >

: > End Sub

: > '

: > Call SetHeaders()

: > %>

: >

: > Alternatively, how are you creating the 2nd recordset? Using a SQL

select

: > statement? or are you reusing a recordset that you used to insert the

: data

: > in the first place?

: >

: > Cheers

: > Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Message #5 by "p" <paul@m...> on Tue, 18 Dec 2001 18:26:19
<%

request("status")

request("pidx")

Usridx = session("usridx")



'Add to favorites here

if (status = "add") then

   set addUserFavorites_rs = initializeRS("Select * from favorites where 

Usridx="&usridx&" and P_Data_Idx="&pidx)

   if addUserFavorites_rs.EOF = true then

      addUserFavorites_rs.addnew

         addUserFavorites_rs("usridx") = Usridx

         addUserFavorites_rs("P_Data_Idx") = pidx

      addUserFavorites_rs.update

      addUserFavorites_rs.close

   end if

      set addUserFavorites_rs = nothing

end if

%>

<html>

<body>

<%

'Get the users favorite parts

Dim getUserFavorites_rs



set getUserFavorites_rs = initializeRS("SELECT P.Partno, P.Descr, 

P.P_Data_Idx, P.mfg_idx, P.average_lead_time FROM favorites F, P_data P 

WHERE F.P_Data_Idx = P.P_Data_Idx AND F.Usridx="&Usridx)

  if getUserFavorites_rs.EOF <> true then

%>

Display The Parts HERE!

<% end if %>

</body>

</html>



Hopefully you get the jist of it.  The part actually gets added at the top 

(I have checked the database manually to verify) but the new part will not 

be displayed in the HTML until I refresh the page. Hopefully, this helps.



Thanks again,

PJ



> Can you provide some code please?

> 

> Cheers

> Ken

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> From: "p" <paul@m...>

> Subject: [asp_databases] Re: Problems with a Select after an Insert

> 

> 

> : I've tried expiring the cache and I am using a completely new 

recordset.

> :

> : > Are you expiring your pages? and/or preventing caching

> : >

> : > <%

> : > Sub SetHeaders( _

> : >     )

> : >

> : >     Response.ExpiresAbsolute = #1/1/1980#

> : >     Response.CacheControl = "private"

> : >     Response.AddHeaders "pragma", "no-cache"

> : >

> : > End Sub

> : > '

> : > Call SetHeaders()

> : > %>

> : >

> : > Alternatively, how are you creating the 2nd recordset? Using a SQL

> select

> : > statement? or are you reusing a recordset that you used to insert the

> : data

> : > in the first place?

> : >

> : > Cheers

> : > Ken

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 


  Return to Index