hi,
can some help me in this regard
i m entering some values in my databse from my asp page. for this i m using a submit button which submit the form to a new page that is 'insert.asp'. this page perform insertion and redirect it back to my previos page.
can i not do this insertion on the same page?
if i wirte insertin code on the same page it perform insertion for the page refresh also...thats why i m using another page(some people says why user refresh page?..but we can not restrick the user to not to refresh page...)....
so is there any way when i can perform insertion on submit click only and not on page refresh...
or is there any way to do call two different server side function(or perform two different code) on two different buttons.
pls help....
thnx in advance..
Rahul
11 12971
Hi Rahul,
So if I've evaluated what you've asked for correctly, you are entering values into a form, then sending these to the page "insert.asp " and once inserted, you are redirecting the user back to the input page (for the purposes of example, "input.asp" )?
If you can provide your sample code for "input.asp" and "insert.asp " then I can walk you through it and show you how to submit the data to the same ASP page, process it and do the redirect, all in a single page.
If you can't provide your sample code then I can only advise you - use a hidden input in your form in "input.asp" and submit the data to "input.asp" - you can then check whether the user has refreshed using some simple error- and value-checking, and then load up input.asp again.
Best regards,
medicineworker
hi
thnx for ur interesr in prob
it was my insert .asp
<html>
<head>
<title>Dispal y on same page</title>
</head>
<body >
<form>
</form>
<%
set Conn = server.createob ject("adodb.con nection")
Conn.Open "driver={sq l server}; server=SERVERNA ME; database=DATABA SE; uid=UID; pwd=PASSWORD;"
sql="INSERT TABLE info VALUES"
sql=sql & "( '" & Request.Form("N ame") & "',"
sql=sql & "'" & Request.Form("d ob") & "',"
sql=sql & "'" & Request.Form("g ender") & "',"
sql=sql & "'" & Request.Form("d egree") & "',"
sql=sql & "'" & Request.Form("a ddress") & "')"
conn.Execute sql,recAffected
Response.write( "inserted!!!!!! !!!!!!!!!")
conn.close
Response.redire ct("ASPAssignme nt2.asp")
%>
</body>
</html>
and here is my first page ASPAssignmentas p
<html>
<head>
<title>Dispal y on same page</title>
<script language=javasc ript >
function DateExists(valu e)
{
d = new Date()
var year = value.substring (value.lastInde xOf("/")+1);
var date = value.substring (value.indexOf( "/")+1 , value.lastIndex Of("/"));
var month = value.substring (0,value.indexO f("/"));
if( month == 4 || month == 6 || month == 9 || month == 11 )
{
if(date > 30) { return false; }
else {return true;}
}
else if (month == 2)
{
if ( year%4 == 0 )
{
if (date > 29) { return false;}
else {return true;}
}
else
{
if (date > 28) { return false;}
else { return true; }
}
}
else if( month ==1 || month == 3|| month ==5 || month == 7 || month == 8 || month == 10 || month == 12)
{
if ( date >31) { return false; }
else {return true; }
}
}
function validate()
{
var str=""
if(document.get ElementById("tx tName").value== "")
{
str+="Name can not be blank \n"
}
if (document.getEl ementById("txtD OB").value==" ")
{
str+="Please enter date of birth \n"
}
else
{
var RegularExpressi on = /^([0][1-9]|[1-9]|[1][0-2])(\/)([0][1-9]|[1-9]|[1-2][0-9]|[3][0-1])(\/)([0-9]{4})$/;
if (RegularExpress ion.test(docume nt.getElementBy Id("txtDOB").va lue)!=true)
{
str+="Please enter a correct value in the date field \n"+ "the date must be in the format MM/DD/YYYY \n"
}
}
if (DateExists(doc ument.getElemen tById("txtDOB") .value)==false)
{
str+="Date entered as date of birth do not exist \n"
}
if (document.getEl ementById("Male ").checked == false && document.getEle mentById("Femal e").checked == false )
{
str+="Please select gender \n"
}
value=document. getElementById( "txtDOB").v alue
var year = value.substring (value.lastInde xOf("/")+1);
if (d.getFullYear( ) < parseInt(year)+ parseInt(18))
{
str+="age must be greater than 18 years \n"
}
if(document.get ElementById("tx tAddress").valu e=="")
{
str+="Address can not be blank \n"
}
if(str!="")
{
alert("Please correct the following(s) : \n\n" + str)
// window.location .reload();
return false
}
}
</script>
<%
set Conn = server.createob ject("adodb.con nection")
Conn.Open "driver={sq l server}; server=SERVER NAME; database=DATABA SE; uid=UID; pwd=PASSWORD;"
set rs=Server.Creat eObject("ADODB. recordset")
rs.Open "Select * from TABLE ", conn
response.Write( "<P>")
%>
<%
if(rs.EOF<>true ) then
select case (rs("degree"))
case "BE"
BE="selected"
case "B.TECH"
BTECH="selected "
case "MCA"
MCA="selected"
case "MBA"
MBA="selected"
case "M.TECH"
MTECH="selected "
end select
select case (rs("gender"))
case "Male"
m="checked"
case "Female"
f="checked"
end select
end if
%>
</head>
<body style="font-family:Verdana ; font-size:smaller ">
<form id="form1" method=get action="ASPAssi gnment2.asp" >
<br />
<table style="font-family:Verdana; font-size:10pt ">
<tr>
<td align="right" > Name : </td>
<td><input type=text id=txtName name=Name value="<%if (rs.EOF<>true)t hen response.Write( rs("Name")) end if%>" style="width: 300px" /></td>
</tr>
<tr>
<td align="right">D OB : </td>
<td><input type=text id=txtDOB name=DOB value="<%if (rs.EOF<>true)t hen response.Write( rs("dob")) end if%>" style="width: 300px" /></td>
</tr>
<tr>
<td align="right"> Gender : </td>
<td><input type=radio value=Male <%=m %> id=Male name=Gender style="width: 25px" />Male
<input type=radio value=Female <%=f %> id=Female name=Gender style="width: 25px" /> Female </td>
</tr>
<tr>
<td align="right"> Qualification : </td>
<td><select style="width: 300px" id= ddlDegree name=degree>
<option value="BE" <%=BE %> >BE</option>
<option value="B.TECH" <%=BTECH %>>B TECH</option>
<option value="MCA" <%=MCA %>>MCA</option>
<option value="MBA" <%=MBA %>>MBA</option>
<option value="M.TECH" <%=MTECH %>>M TECH</option>
</select></td>
</tr>
<tr>
<td align="right">A ddress :</td>
<td><input type=text id=txtAddress name=address value="<%if (rs.EOF<>true)t hen response.Write( rs("address")) end if%>" style="width: 300px" /></td>
</tr>
<tr>
<td align="right"></td>
<td><input type=submit name=submit value="Submit" onclick="return validate()" style="font-size: x-small; font-family: Verdana"/></td>
</tr>
</table>
<br />
</form>
<%
do while not rs.EOF
for each x in rs.fields
response.write( x.name)
response.write( " = ")
response.write( x.value)
response.Write( "<br>")
next
rs.MoveNext
Response.Write( "<br><br>")
loop
conn.Close
%>
</body>
</html>
now i have done this for doing on the same page all the things. now problem is solved but pls let me know if i can do better that this.(pls dont check for nameing conventions ..its my learning application...i know it is little difficult to understand due ot lack of that/...)
pls consider...
thnx again
<html>
<head >
<title>Move </title>
<script language=javasc ript >
function DateExists(valu e)
{
d = new Date()
var year = value.substring (value.lastInde xOf("/")+1);
var date = value.substring (value.indexOf( "/")+1 , value.lastIndex Of("/"));
var month = value.substring (0,value.indexO f("/"));
if( month == 4 || month == 6 || month == 9 || month == 11 )
{
if(date > 30) { return false; }
else {return true;}
}
else if (month == 2)
{
if ( year%4 == 0 )
{
if (date > 29) { return false;}
else {return true;}
}
else
{
if (date > 28) { return false;}
else { return true; }
}
}
else if( month ==1 || month == 3|| month ==5 || month == 7 || month == 8 || month == 10 || month == 12)
{
if ( date >31) { return false; }
else {return true; }
}
}
function validate()
{
var str=""
if(document.get ElementById("na me").value==" ")
{
str+="Name can not be blank \n"
}
if (document.getEl ementById("dob" ).value=="")
{
str+="Please enter date of birth \n"
}
else
{
var RegularExpressi on = /^([0][1-9]|[1-9]|[1][0-2])(\/)([0][1-9]|[1-9]|[1-2][0-9]|[3][0-1])(\/)([0-9]{4})$/;
if (RegularExpress ion.test(docume nt.getElementBy Id("dob").value )!=true)
{
str+="Please enter a correct value in the date field \n"+ "the date must be in the format MM/DD/YYYY \n"
}
}
if (DateExists(doc ument.getElemen tById("dob").va lue)==false)
{
str+="Date entered as date of birth do not exist \n"
}
if (document.getEl ementById("Male ").checked == false && document.getEle mentById("Femal e").checked == false )
{
str+="Please select gender \n"
}
value=document. getElementById( "dob").valu e
var year = value.substring (value.lastInde xOf("/")+1);
if (d.getFullYear( ) < parseInt(year)+ parseInt(18))
{
str+="age must be greater than 18 years \n"
}
if(document.get ElementById("ad dress").value== "")
{
str+="Address can not be blank \n"
}
if(str!="")
{
alert("Please correct the following(s) : \n\n" + str)
return false
}
}
</script>
<% if (session("count ")="" or session("count" )=0)then
session("count" )=0
end if
dim total
total = 0
set Conn = server.createob ject("adodb.con nection")
Conn.Open "driver={sq l server}; server=SERVER; database=DATABA SE; uid=UID; pwd=PASSWORD;"
set rs=Server.Creat eObject("ADODB. recordset")
rs.Open "Select * from TABLE ", conn
do while not rs.EOF
rs.MoveNext
total=total+1
loop
rs.Close
rs.Open "Select * from TABLE ", conn
if (request.Form(" button")="next" and rs.EOF<>true) then
if( session("count" )<total-1) then
session("count" )=session("coun t")+1
rs.Move(session ("count"))
else
rs.Move(total-1)
response.Write( "you are on last record")
end if
// response.Write( rs("name"))
end if
if (request.Form(" button")="prev" and rs.EOF<>true) then
if(session("cou nt")>0) then
session("count" )=session("coun t")-1
rs.Move(session ("count"))
else
rs.Move(session ("count"))
Response.Write( "you are on first record")
end if
// response.Write( rs("name"))
end if
if (request.Form(" button")="First " and rs.EOF<>true) then
session("count" )=0
rs.Move(session ("count"))
// response.Write( rs("name"))
end if
if (request.Form(" button")="Last" and rs.EOF<>true ) then
session("count" )=total-1
rs.Move(session ("count"))
// response.Write( session("name") )
end if
%>
</head>
<body style="font-family:Verdana; font-size:smaller" >
<form name=form id= form method=post style="font-family:Verdana; font-size:smaller" >
<table style="font-family:Verdana; font-size:10pt " >
<tr>
<td> Name :</td><td><input type=text name=name id=name value = "<%if(rs.eof<>t rue)then response.write( rs("name"))end if%>" style="width: 296px" /></td> <br />
</tr>
<tr>
<td>DOB :</td><td><input type=text name=dob id=dob value = "<%if(rs.eof<>t rue)then response.write( rs("dob"))end if%>" style="width: 296px" /></td><br />
</tr>
<tr>
<td>Gender :</td><td><input type=radio value=Male <%if(rs.eof<>tr ue) then if(rs("gender") ="Male") then response.write( "checked") end if end if%> id=Male name=Gender style="width: 25px" />Male
<input type=radio value=Female <%if(rs.eof<>tr ue) then if(rs("gender") )="Female" then response.write( "checked") end if end if%> id=Female name=Gender style="width: 25px" /> Female</td> <br />
</tr>
<tr>
<td> Degree:</td><td> <select style="width: 300px" id= ddlDegree name=degree>
<option value="BE"<%if( rs.eof<>true) then if(rs("degree") ="BE") then response.write( "Selected") end if end if%> >BE</option>
<option value="B.TECH" <%if(rs.eof<>tr ue) then if(rs("degree") ="B.TECH") then response.write( "Selected") end if end if%>>B TECH</option>
<option value="MCA" <%if(rs.eof<>tr ue) then if(rs("degree") ="MCA") then response.write( "Selected") end if end if%>>MCA</option>
<option value="MBA" <%if(rs.eof<>tr ue) then if(rs("degree") ="MBA") then response.write( "Selected") end if end if%>>MBA</option>
<option value="M.TECH"< %if(rs.eof<>tru e) then if(rs("degree") ="M.TECH") then response.write( "Selected") end if end if%>>M TECH</option>
</select></td>
</tr>
<TR>
<td>Address:</td><td> <input type=text name="address" id=address value = "<%if(rs.eof<>t rue)then response.write( rs("address"))e nd if%>" style="width: 298px" /></td><br />
</TR>
<tr><td></td><td>
<input type=submit name=button id=btnFirst value="First" style="width: 70px" />
<input type=submit name=button id=btnPrev value="prev" style="width: 70px" />
<input type=submit name=button id=btnNext value="next" style="width: 70px" />
<input type=submit name=button id=btnLast value="Last" style="width: 70px" />
<input type=submit name=button id=btnInsert value="Insert" onclick="return validate()" style="width: 70px" /></td>
</TR>
</table>
</form>
<br />
</body>
</html>
<%
rs.Close
rs.Open "Select * from TABLE ", conn
do while not rs.EOF
for each x in rs.fields
response.write( x.name )
response.write( " = ")
response.write( x.value)
response.Write( "<br>")
next
rs.MoveNext
Response.Write( "<br><br>")
loop
rs.Close
conn.Close
%>
<%
if (request.Form(" button")="Inser t") then
set Conn = server.createob ject("adodb.con nection")
Conn.Open "driver={sq l server}; server=SERVER; database=DATABA SE; uid=UID; pwd=PASSWORD;"
sql="INSERT INTO info VALUES"
sql=sql & "( '" & Request.Form("N ame") & "',"
sql=sql & "'" & Request.form("d ob") & "',"
sql=sql & "'" & Request.form("g ender") & "',"
sql=sql & "'" & Request.form("d egree") & "',"
sql=sql & "'" & Request.form("a ddress") & "')"
conn.Execute sql
conn.close
Response.redire ct("Move.asp")
end if
%>
jhardman 3,406
Recognized Expert Specialist
I think I would have taken a slightly different approach, when you click the submit button a new input is added named "submit" and it is given the value of whatever value the submit has, so if you had the following as your submit button: [code=html]<input type="submit" name="submit" value="submit">[/html] and then you check for this value before you do the update, you will get the correct result: - if request("submit") <> "" then
-
'do the update
-
end if
now if the user might hit the "refresh" button accidentally after submitting the form and you want to prevent re-entering the data you might do it like this: - if request("submit") <> "" then
-
if formatDateTime(session("lastUpdate"),2) = formatDateTime(date(), 2) then
-
'info was already updated today, so ignore
-
else
-
session("lastUpdate") = now()
-
'do update
-
end if
-
end if
Jared
hi jared
thnx for ur interest in this
but do yu think it would be a good approch. it wont allow the user to insert any value again on the same browser. i wnated to do that also...
what i m doinng now is to disabled insert button and adding a new button to ie 'add new value' and which resetal the fields and then enabled insert button..
and also i can not make insert button's value as submit coz i have more butons on my page ie. prev, next , first and last u can see in the code..updated code is here .. pls go through that pls let me know i m going wrong...or any better can be done.........
thnx again! -
<%@ LANGUAGE="VBSCRIPT" %>
-
<% OPTION EXPLICIT %>
-
-
-
<%
-
'CHECKING FOR THE FIRST RUN FOR THE SESSION
-
if (session("nRowID")="" or session("nRowID")=0)then
-
session("nRowID")=0
-
end if
-
-
dim m_nTotNoOfRecords, m_connADOASP, m_rsInfo, m_sQuery
-
m_nTotNoOfRecords = 0
-
set m_connADOASP = server.createobject("ADODB.connection")
-
set m_rsInfo=Server.CreateObject("ADODB.recordset")
-
-
session("lastpdated")=now
-
response.Write(formatDateTime(session("lastUpdate"),2) )
-
-
m_connADOASP.Open "driver={sql server}; server=rahul\sqlexpress; database=ADOASP; uid=sa; pwd=;"
-
m_rsInfo.Open "SELECT id, name, dob, gender, degree, address FROM Info ", m_connADOASP
-
-
if (request.Form("button")="Next" and m_rsInfo.EOF<>true) then
-
if( session("nRowID") < session("nTotNoOfRecords")-1) then 'IF POINTER IS NOT ON LAST RECORD'
-
session("nRowID")=session("nRowID")+1
-
m_rsInfo.Move(session("nRowID"))
-
else
-
m_rsInfo.Move(session("nTotNoOfRecords")-1)
-
response.Write("you are on last record")
-
end if
-
end if
-
-
if (request.Form("button")="Prev" and m_rsInfo.EOF<>true) then
-
if(session("nRowID")>0) then ' IF POINTER IS NOT ON FIRST RECORD'
-
session("nRowID")=session("nRowID")-1
-
m_rsInfo.Move(session("nRowID"))
-
else
-
m_rsInfo.Move(session("nRowID"))
-
Response.Write("you are on first record")
-
end if
-
end if
-
-
if (request.Form("button")="First" and m_rsInfo.EOF<>true) then
-
session("nRowID")=0
-
m_rsInfo.Move(session("nRowID"))
-
end if
-
-
if (request.Form("button")="Last" and m_rsInfo.EOF<>true ) then
-
session("nRowID")=session("nTotNoOfRecords")-1
-
m_rsInfo.Move(session("nRowID"))
-
end if
-
-
-
%>
-
-
<html>
-
<head >
-
<title>Move </title>
-
-
<script language=javascript >
-
<%
-
'FUNCTION IS CHECKING FOR THE DATE IF EXISTS IN THE CALENDER
-
%>
-
function DateExists(value)
-
{
-
d = new Date()
-
var year = value.substring(value.lastIndexOf("/")+1);
-
var date = value.substring(value.indexOf("/")+1 , value.lastIndexOf("/"));
-
var month = value.substring(0,value.indexOf("/"));
-
-
if( month == 4 || month == 6 || month == 9 || month == 11 )
-
{
-
if(date > 30) { return false; }
-
else {return true;}
-
}
-
else if (month == 2)
-
{
-
if ( year%4 == 0 )
-
{
-
if (date > 29) { return false;}
-
else {return true;}
-
}
-
else
-
{
-
if (date > 28) { return false;}
-
else { return true; }
-
}
-
}
-
else if( month ==1 || month == 3|| month ==5 || month == 7 || month == 8 || month == 10 || month == 12)
-
{
-
if ( date >31) { return false; }
-
else {return true; }
-
}
-
-
-
-
}
-
-
<%
-
'PERFORMING VALIDATION BEFORE INSERTION INTO DATABASE
-
%>
-
function validate()
-
{
-
-
var str=""
-
if(document.getElementById("name").value=="")
-
{
-
str+="Name can not be blank \n"
-
}
-
if (document.getElementById("dob").value=="")
-
{
-
str+="Please enter date of birth \n"
-
}
-
else
-
{
-
var RegularExpression = /^([0][1-9]|[1-9]|[1][0-2])(\/)([0][1-9]|[1-9]|[1-2][0-9]|[3][0-1])(\/)([0-9]{4})$/;
-
-
if (RegularExpression.test(document.getElementById("dob").value)!=true)
-
{
-
str+="Please enter a correct value in the date field \n"+ "the date must be in the format MM/DD/YYYY \n"
-
}
-
}
-
-
if (DateExists(document.getElementById("dob").value)==false)
-
{
-
str+="Date entered as date of birth do not exist \n"
-
}
-
-
if (document.getElementById("Male").checked == false && document.getElementById("Female").checked == false )
-
{
-
str+="Please select gender \n"
-
}
-
-
value=document.getElementById("dob").value
-
var year = value.substring(value.lastIndexOf("/")+1);
-
-
if (d.getFullYear() < parseInt(year)+ parseInt(18))
-
{
-
str+="age must be greater than 18 years \n"
-
}
-
if(document.getElementById("address").value=="")
-
{
-
str+="Address can not be blank \n"
-
}
-
-
if(str!="")
-
{
-
alert("Please correct the following(s) : \n\n" + str)
-
// window.location.reload();
-
return false
-
}
-
-
}
-
-
function funResetControls()
-
{
-
document.getElementById("name").value=""
-
document.getElementById("dob").value=""
-
document.getElementById("address").value=""
-
document.getElementById("Male").checked=false
-
document.getElementById("Female").checked=false
-
document.getElementById("degree").value="BE"
-
document.getElementById("btnInsert").disabled=false
-
}
-
-
</script>
-
-
-
</head>
-
<body style="font-family:Verdana; font-size:smaller" >
-
<form name=form id= form method=post style="font-family:Verdana; font-size:smaller" >
-
<table style="font-family:Verdana; font-size:10pt" >
-
<tr>
-
<td> Name :</td><td><input type=text name=name id=name value = "<%if(m_rsInfo.eof<>true)then response.write(m_rsInfo.fields("name").value)end if%>" style="width: 296px" /></td> <br />
-
</tr>
-
<tr>
-
<td>DOB :</td><td><input type=text name=dob id=dob value = "<%if(m_rsInfo.eof<>true)then response.write(m_rsInfo.fields("dob").value)end if%>" style="width: 296px" /></td><br />
-
</tr>
-
<tr>
-
<td>Gender :</td><td><input type=radio value=Male <%if(m_rsInfo.eof<>true) then if(m_rsInfo.fields("gender").value="Male") then response.write("checked") end if end if%> id=Male name=Gender style="width: 25px" />Male
-
<input type=radio value=Female <%if(m_rsInfo.eof<>true) then if(m_rsInfo.fields("gender").value)="Female" then response.write("checked") end if end if%> id=Female name=Gender style="width: 25px" /> Female</td> <br />
-
</tr>
-
<tr>
-
<td> Degree:</td><td> <select style="width: 300px" id= ddlDegree name=degree>
-
<option value="BE"<%if(m_rsInfo.eof<>true) then if(m_rsInfo.fields("degree").value="BE") then response.write("Selected") end if end if%> >BE</option>
-
<option value="B.TECH" <%if(m_rsInfo.eof<>true) then if(m_rsInfo.fields("degree").value="B.TECH") then response.write("Selected") end if end if%>>B TECH</option>
-
<option value="MCA" <%if(m_rsInfo.eof<>true) then if(m_rsInfo.fields("degree").value="MCA") then response.write("Selected") end if end if%>>MCA</option>
-
<option value="MBA" <%if(m_rsInfo.eof<>true) then if(m_rsInfo.fields("degree").value="MBA") then response.write("Selected") end if end if%>>MBA</option>
-
<option value="M.TECH"<%if(m_rsInfo.eof<>true) then if(m_rsInfo.fields("degree").value="M.TECH") then response.write("Selected") end if end if%>>M TECH</option>
-
</select></td>
-
</tr>
-
<TR>
-
<td>Address:</td><td> <input type=text name="address" id=address value = "<%if(m_rsInfo.eof<>true)then response.write(m_rsInfo.fields("address").value)end if%>" style="width: 298px" /></td><br />
-
</TR>
-
<tr><td></td><td>
-
<input type=submit name=button id=btnFirst value="First" style="width: 70px" />
-
<input type=submit name=button id=btnPrev value="Prev" style="width: 70px" />
-
<input type=submit name=button id=btnNext value="Next" style="width: 70px" />
-
<input type=submit name=button id=btnLast value="Last" style="width: 70px" />
-
</td>
-
</TR>
-
<tr>
-
<td></td>
-
<td><input type=button name=btnAddNew id=btnAddNew value="Add New Value" onclick="funResetControls()" style="width: 103px"/>
-
<input type=submit name=button id=btnInsert value="Insert" onclick="return validate()" style="width: 103px" disabled="disabled" /></td>
-
</tr>
-
</table>
-
</form>
-
-
<br />
-
-
</body>
-
</html>
-
-
<%
-
-
m_rsInfo.Close
-
-
'DISPLAY ALL THE RECORDS ON THE PAGE
-
m_rsInfo.Open "SELECT id, name, dob, gender, degree, address FROM Info ", m_connADOASP
-
dim x
-
do while not m_rsInfo.EOF
-
for each x in m_rsInfo.fields
-
response.write(x.name )
-
response.write(" = ")
-
response.write(x.value)
-
response.Write("<br>")
-
next
-
-
m_rsInfo.MoveNext
-
m_nTotNoOfRecords=m_nTotNoOfRecords+1
-
Response.Write("<br><br>")
-
-
loop
-
session("nTotNoOfRecords")= m_nTotNoOfRecords
-
m_rsInfo.Close
-
m_connADOASP.Close
-
-
%>
-
<%
-
-
if (request.Form("button")="Insert") then
-
-
set m_connADOASP = server.createobject("adodb.connection")
-
m_connADOASP.Open "driver={sql server}; server=rahul\sqlexpress; database=ADOASP; uid=sa; pwd=;"
-
-
m_sQuery="INSERT INTO info VALUES"
-
m_sQuery=m_sQuery & "( '" & Request.Form("Name") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("dob") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("gender") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("degree") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("address") & "')"
-
-
-
m_connADOASP.Execute m_sQuery
-
m_connADOASP.close
-
Response.redirect("Move.asp")
-
-
end if
-
-
%>
jhardman 3,406
Recognized Expert Specialist
You have just posted over 250 lines of code. It is very difficult to read through someone else's code for that long. It would be much easier if you posted two or three lines to illustrate your problem. - if condition
-
'you don't need to give the update code unless you want me to look specifically atr that
-
end if
by the way, please remember to put your code in code tags - there is a button marked # which places code within the correct tags.
My code was just a simple example of one way to restrict user updates. There are hundreds of ways to do it, but essentially they will all use if...then statements to determine if a value should be updated or if the info was sent inadvertantly.
I don't want to read through your whole code, but if you have a specific question, post the part of the code that is giving you trouble.
Jared
hi jared
sorry for any inconvienvience . as i m new to all this and i m not familier with all this..and i m learnig asp.
but thnx for your help...i m not facing any prob in this now...insertion/navigation all is working..but i think thwrw may be some better way.... my question is that ur previos code wont allow me to insert a new value again into same browser...right ??..does it??...
so i was asking for any better solution....
thnx again
rahul
jhardman 3,406
Recognized Expert Specialist
Rahul,
hey, we don't have a character limit, so there is no reason to use SMS speak like "ur" instead of "your". People who don't spend a lot of time SMSing have a hard time understanding that, so we ask people to use as correct English as they can manage when they post here.
Back to your question... the code snippet I gave does indeed limit users to one update per day per session, but any ASP solution is going to look very similar. You will need to decide the best way to distinguish between desired updates and undesired, and make the only updates happen when you want it to. There are a million ways to do this, you will need to come up with the best solution for you. For example, you could have the submit button disabled unless a change has been made- this could be handled quite easily with javascript, and if the page was refreshed, the submit button would be disabled again.
Jared
hi Jared
Thank you very much for your lots of lots of help.......
i have done this already. you can check that if you go through the code(i know you wont like to go through that all and reason is obvious) ok leave that all. i made a new button 'Add New Value" that enabled the "insert" button and reset all the controls. and also performing validations before insertion on the page for nulll values and special characters..
now on page load i have disabled "insert" button. here is the specific code for insert operation. - if (request.Form("button")="Insert") then
-
-
set m_connmyASP = server.createobject("adodb.connection")
-
m_connmyASP.Open "driver={sql server}; server=SERVER; database=DATABASE; uid=UID; pwd=PWD;"
-
-
m_sQuery="INSERT INTO info VALUES"
-
m_sQuery=m_sQuery & "( '" & Request.Form("Name") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("dob") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("gender") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("degree") & "',"
-
m_sQuery=m_sQuery & "'" & Request.form("address") & "')"
-
-
-
m_connmyASP.Execute m_sQuery
-
m_connmyASP.close
-
Response.redirect("Move.asp")
-
-
end if
now problem here is that i have to redirect it to the same page again at last.. means again whole post back whole page load and everything..if i do not use this then "request.form(" button").value" always remains same ie "Insert" for page refresh...the insertion performed on each refresh even "insert" button is disabled.
can you please tell if we can do anything better.
and i will try to use proper english from the next time.
thanks again
Rahul
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: mrbog |
last post by:
Tell me if my assertion is wrong here:
The only way to prevent session hijacking is to NEVER store
authentication information (such as name/password) in the session.
Well, to never authenticate a user from information you got from the
session. Each secure app on a site must challenge the user for name
and password, each and every time the...
|
by: laura |
last post by:
I'm doing a page which gathers some text in the form of a text box in a
<form>. This text is saved to a text file, notices.txt and I want to be able
to display the saved text on the page, as soon as they click the SUBMIT
button - is this possible?
At the moment I have a hyperlink called "back" which, once they have entered
the text and they...
|
by: iwearwatches |
last post by:
Group,
What a root canal.
Here is what I have:
I have a page that has several layers that I will either show/hide
based on a graphic/tab that the user clicks. (works perfectly)
|
by: Bill Cohagan |
last post by:
I'm constructing an ASP app with a frameset on the home html page. From
frame A I need to referesh the page in frame B when a button click occurs on
a button in Frame A (server side event handler).
To accomplish this I've included some client side script in the page being
built in frame A such that whenever it is received by the browser it...
|
by: Alan Z. Scharf |
last post by:
1. I have a chain of six asynch callbacks initiated by a button, and want
the page to refresh at the end of each callback to display
A. Results of a SQLServer query showing cumulative running time, and
B. A progress bar.
2. I have this working with a refresh timer:
<META http-equiv="refresh" content="5">
| |
by: Mike Moore |
last post by:
Is there an easy way to check if Java Script is enabled in the MS Internet
Explorer browser for versions 5.0 and above?
Also, how might I test this?
|
by: Ambush |
last post by:
My aspx is called from an ASP page. I process the request and then
call another ASP page with a few hidden inputs. Currently, when the
page processes, the user is complaining that my code is running too
fast and that my "Please Wait" page flashes by too quickly. I can't
put an inline wait/sleep command, as the page doesn't refresh until the...
|
by: Ibrahim. |
last post by:
Hi,
I have a login page, the problem I'm facing is like this;
1. Login page with submit button (being default button);
2. When first time the page is submitted then submit code is called.
3. Again when page refresh is done by (f5) then submit button is fired
implicitly.
|
by: Dan |
last post by:
Hi,
i'm not sure to understand the difference between refreshing the pagina by
clicking on 'refresh' in the browser and a postback.
What i think it is:
Suppose a page with a form containing a textbox and a dropdowlist: and a
button to start something n code-behind:
a refresh doesn't send any value back to the server but with a postback,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |