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.dt d">
<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("FirstN ame")<>"" then
set conn = server.createob ject("adodb.con nection")
conn.open("Prov ider=Microsoft. Jet.OLEDB.4.0;d ata source=" &
server.MapPath( "target\Target1 .mdb"))
SQLStmt = "SELECT count(*) as rv FROM tblPerson WHERE FirstName='" &
Request("FirstN ame") & "';"
vRecNo = ""
Set oRS = conn.execute(SQ LStmt)
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("FirstN ame") & "');"
conn.execute(SQ LStmt)
SQLStmt = "SELECT RecNo FROM tblPerson WHERE FirstName='" &
Request("FirstN ame") & "';"
Set oRS = conn.execute(SQ LStmt)
SQLStmt = ""
vRecNo = oRS("RecNo")
Session("aRecNo ") = vRecNo
oRS.Close
Set oRS = Nothing
end if
end if
end sub
%>
<%
Response.CacheC ontrol = "no-cache"
Response.AddHea der "Pragma", "no-cache"
Response.Expire s = 0
if Session("aRecNo ") <> "" then
set conn = server.createob ject("adodb.con nection")
conn.open("Prov ider=Microsoft. Jet.OLEDB.4.0;d ata source=" &
server.MapPath( "target\Target1 .mdb"))
SQLStmt = "SELECT * FROM tblPerson WHERE RecNo=" & Session("aRecNo ")
Set oRS = conn.execute(SQ LStmt)
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.a sp" >
<input name="Submit" type="submit" value="Submit"
onclick="locati on.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.dt d">
<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("FirstN ame")<>"" then
set conn = server.createob ject("adodb.con nection")
conn.open("Prov ider=Microsoft. Jet.OLEDB.4.0;d ata source=" &
server.MapPath( "target\Target1 .mdb"))
SQLStmt = "SELECT count(*) as rv FROM tblPerson WHERE FirstName='" &
Request("FirstN ame") & "';"
vRecNo = ""
Set oRS = conn.execute(SQ LStmt)
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("FirstN ame") & "');"
conn.execute(SQ LStmt)
SQLStmt = "SELECT RecNo FROM tblPerson WHERE FirstName='" &
Request("FirstN ame") & "';"
Set oRS = conn.execute(SQ LStmt)
SQLStmt = ""
vRecNo = oRS("RecNo")
Session("aRecNo ") = vRecNo
oRS.Close
Set oRS = Nothing
end if
end if
end sub
%>
<%
Response.CacheC ontrol = "no-cache"
Response.AddHea der "Pragma", "no-cache"
Response.Expire s = 0
if Session("aRecNo ") <> "" then
set conn = server.createob ject("adodb.con nection")
conn.open("Prov ider=Microsoft. Jet.OLEDB.4.0;d ata source=" &
server.MapPath( "target\Target1 .mdb"))
SQLStmt = "SELECT * FROM tblPerson WHERE RecNo=" & Session("aRecNo ")
Set oRS = conn.execute(SQ LStmt)
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.a sp" >
<input name="Submit" type="submit" value="Submit"
onclick="locati on.reload();" />
<textarea name="FirstName "><%=vFirstName %></textarea>
</form>
</body>
</html>
Comment