I
Isabel
hi everyone,
I have an annoying problem of with asp.
Right now, when i type in data in textbox and hit submit, the text
entered stays displayed in the textbox, however if I type in new data,
it will not stay but revert to what was previously written in. BUT if I
keep trying (by typing in new data and hitting submit) eventually one
of the attempts will work (1 out of 20 tries the new data will remain
in the textbox, all other attempts it reverts to what was there prior)
Does anyone know what is wrong? I thought something was being cached
but i've added all the code i can think of to keep it from caching.
thanks if anyone knows!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
</head>
<%
sub SaveData()
if Request("FirstName")<>"" then
set conn = server.createobject("adodb.connection")
conn.open("Provider=Microsoft.Jet.OLEDB.4.0;data source=" &
server.MapPath("target\Target1.mdb"))
SQLStmt = "SELECT count(*) as rv FROM tblPerson WHERE FirstName='" &
Request("FirstName") & "';"
vRecNo = ""
Set oRS = conn.execute(SQLStmt)
if oRS("RV")<>0 then
oRS.Close
Set oRS = Nothing
else
oRS.Close
Set oRS = Nothing
SQLStmt = " INSERT INTO tblPerson ("
SQLStmt = SQLStmt & "FirstName)"
SQLStmt = SQLStmt & "VALUES ('"
SQLStmt = SQLStmt & Request("FirstName") & "');"
conn.execute(SQLStmt)
SQLStmt = "SELECT RecNo FROM tblPerson WHERE FirstName='" &
Request("FirstName") & "';"
Set oRS = conn.execute(SQLStmt)
SQLStmt = ""
vRecNo = oRS("RecNo")
Session("aRecNo") = vRecNo
oRS.Close
Set oRS = Nothing
end if
end if
end sub
%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = 0
if Session("aRecNo") <> "" then
set conn = server.createobject("adodb.connection")
conn.open("Provider=Microsoft.Jet.OLEDB.4.0;data source=" &
server.MapPath("target\Target1.mdb"))
SQLStmt = "SELECT * FROM tblPerson WHERE RecNo=" & Session("aRecNo")
Set oRS = conn.execute(SQLStmt)
if not oRS.eof then
vFirstName = oRS("FirstName")
end if
oRS.Close
Set oRS = Nothing
end if
%>
<body>
<form name="form1" method="post" onsubmit="<% call SaveData()%>"
Action="test1.asp" >
<input name="Submit" type="submit" value="Submit"
onclick="location.reload();" />
<textarea name="FirstName"><%=vFirstName%></textarea>
</form>
</body>
</html>
I have an annoying problem of with asp.
Right now, when i type in data in textbox and hit submit, the text
entered stays displayed in the textbox, however if I type in new data,
it will not stay but revert to what was previously written in. BUT if I
keep trying (by typing in new data and hitting submit) eventually one
of the attempts will work (1 out of 20 tries the new data will remain
in the textbox, all other attempts it reverts to what was there prior)
Does anyone know what is wrong? I thought something was being cached
but i've added all the code i can think of to keep it from caching.
thanks if anyone knows!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
</head>
<%
sub SaveData()
if Request("FirstName")<>"" then
set conn = server.createobject("adodb.connection")
conn.open("Provider=Microsoft.Jet.OLEDB.4.0;data source=" &
server.MapPath("target\Target1.mdb"))
SQLStmt = "SELECT count(*) as rv FROM tblPerson WHERE FirstName='" &
Request("FirstName") & "';"
vRecNo = ""
Set oRS = conn.execute(SQLStmt)
if oRS("RV")<>0 then
oRS.Close
Set oRS = Nothing
else
oRS.Close
Set oRS = Nothing
SQLStmt = " INSERT INTO tblPerson ("
SQLStmt = SQLStmt & "FirstName)"
SQLStmt = SQLStmt & "VALUES ('"
SQLStmt = SQLStmt & Request("FirstName") & "');"
conn.execute(SQLStmt)
SQLStmt = "SELECT RecNo FROM tblPerson WHERE FirstName='" &
Request("FirstName") & "';"
Set oRS = conn.execute(SQLStmt)
SQLStmt = ""
vRecNo = oRS("RecNo")
Session("aRecNo") = vRecNo
oRS.Close
Set oRS = Nothing
end if
end if
end sub
%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = 0
if Session("aRecNo") <> "" then
set conn = server.createobject("adodb.connection")
conn.open("Provider=Microsoft.Jet.OLEDB.4.0;data source=" &
server.MapPath("target\Target1.mdb"))
SQLStmt = "SELECT * FROM tblPerson WHERE RecNo=" & Session("aRecNo")
Set oRS = conn.execute(SQLStmt)
if not oRS.eof then
vFirstName = oRS("FirstName")
end if
oRS.Close
Set oRS = Nothing
end if
%>
<body>
<form name="form1" method="post" onsubmit="<% call SaveData()%>"
Action="test1.asp" >
<input name="Submit" type="submit" value="Submit"
onclick="location.reload();" />
<textarea name="FirstName"><%=vFirstName%></textarea>
</form>
</body>
</html>