You are firing off the asp code before the html code is sent to the
client...2 choices
1. break apart the code to do the html stuff first and pass it to a
separate asp to do the asp stuff..or..
2. add an if statement to the asp code so it does the html before the
asp code..
<%
if Request.Form("passit") =3D "Y" then 'don't forget the end if at
the
end.
dim conn
dim rs
dim sql
.
.
.
<head>
<script language=3D"JavaScript">
<!--
function submitit() {
document.form1.passit.value =3D "Y";
return (true);
}
//-->
</script>
</head>
<body><form method=3D"POST" action=3D"test.asp" name=3D"form1"
onSubmit=3D"return submitit()" >
...or just add the javascript to the form...
<form method=3D"POST" action=3D"test.asp" name=3D"form1"
onSubmit=3D"javascript:document.form1.passit.value=3D'Y'" >
<p>Enter folder name:<input type=3D"text" name=3D"T1" size=3D"20"></p>
<INPUT type=3D"hidden" name=3D"passit" value=3D"N">
<input type=3D"submit" value=3D"Submit" name=3D"B1"></p>
</form>
-----Original Message-----
From: tulasi [mailto:lakshmi.jonnadula@w...]
Sent: Friday, March 29, 2002 4:36 AM
To: ASP Databases
Subject: [asp_databases] problem in inserting dato in MS Acess
help
i m a beginnar in asp.i was trying to insert a value into data base by
using request.form.i m checking 2 cases
1.if null form is submit, i want to display error message(in the same
form) 2.if the data i m trying to insert into database is already
exiting
i want to display error message (in the same page)
if neither of these not true i want to exectute insert statment.
i m getting the fellowing error message:
_______________________________________________
Error Type:
Microsoft JET Database Engine (0x80004005)
Field 'folder.foldername' cannot be a zero-length string
code:
________________
<%
dim conn
dim rs
dim sql
sql=3D"select * from folder"
set conn=3Dserver.createObject("ADODB.Connection")
conn.Provider=3D"Microsoft.Jet.OLEDB.4.0"
conn.open "d:\tulasi\tulasi.mdb"
set rs=3Dserver.createObject("ADODB.recordset")
rs.open sql,conn
%>
<html>
<head>
<meta name=3D"GENERATOR" content=3D"Microsoft FrontPage 4.0">
<meta name=3D"ProgId" content=3D"FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<form method=3D"POST" action=3D"test.asp" name=3D"form1">
<p>Enter folder name:<input type=3D"text" name=3D"T1" size=3D"20"></p>
<p> &nb
sp;
&nb
sp;
<input type=3D"submit" value=3D"Submit" name=3D"B1"></p>
</form>
<%
folder=3DRequest.form("T1")
while not rs.EOF
if rs("foldername")=3D " " then %>
no data entered
<%else
if rs("foldername")=3Dfolder then %>
folder already exits..try another name
<% response.redirect("test.asp")
else
conn.execute("insert into folder values('"&folder&"')")
response.redirect("test.asp")
end if
end if
rs.MoveNext
wend
rs.close
set rs=3Dnothing
conn.close
set conn=3Dnothing
%>
</body>
</html>
plz help me in solving this problem.
Thanks
Tulasi.