Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing values and inserting records problem

Status
Not open for further replies.

omoo

Programmer
May 30, 2005
87
US
Hi, I am running the 1st script after a form has been submitted.

Code:
<%
DIM insNAME, insYEAR, insRATING

insNAME = Request.Form("txtselName")
insYEAR = Request.Form("txtselYear")
insRATING = Request.Form("txtselRating")

sqlcheck="select * from subdb_subcon_rating WHERE NAME LIKE '"&insNAME&"' AND YEAR LIKE '"&insYEAR&"'"
Set check = OraDatabase.Execute(sqlcheck)

if check.EOF then

	sql="INSERT into subdb_subcon_rating(NAME, YEAR, RATING) values ('"&insNAME&"','"&insYEAR&"','"&insRATING&"')"
	Set objRS = OraDatabase.Execute(sql)	
%>
	<script language="VBScript">	
	MsgBox "Records have been inserted",64,"Alert"
	window.location= "input_records.asp"
	</script>
<%
else
%>
	<form name="update_subcon_ratings_records" method="Get" action="this.form.submit()">
	<input type=hidden name="frmNAME" value="insNAME">
	<input type=hidden name="frmYEAR" value="insYEAR">
	<input type=hidden name="frmRATING" value="insRATING">
	</form>

	<script language="VBScript">
	returnvalue=MsgBox("Records already exist in Database!"& vbCrLf &"Do you want to overwrite the records?",36,"Alert")

	if returnvalue=6 then 
		window.location="update_subcon_ratings_records.asp"
	else 
		MsgBox "Records NOT inserted",16,"Alert"
		history.go(-1)
	end if
	</script>
<%
end if
%>

It will check if the input values are already in the database. If not, it will insert the data with a opo-up saying data are inserted. If no, it will have a pop-up which will ask for confirmation to overwrite the records in the database. if the user click no, it will go back to the original form with a pop up saying records not inserted. If yes, it will go to the 2nd script which will update the records in the database with a pop-up saying records inserted.

However, I am unable to parse the value from the 1st scrip to the 2nd script and also the 2nd script cannot seemed to work. Can anyone help?

Code:
<%
DIM updNAME, updYEAR, updRATING

updNAME = Request.Form("frmNAME")
updYEAR = Request.Form("frmYEAR")
updRATING = Request.Form("frmRATING")

response.write("frmNAME")
	


	OraDatabase.Execute("UPDATE subdb_subcon_rating SET RATING = '"&updRATING&"' WHERE NAME LIKE '"&updNAME&"' AND YEAR LIKE '"&updYEAR&"'")
	%>
	<script language="VBScript">
	MsgBox ("Records have been inserted",64,"Alert") 
	window.location="input_records.asp"
	</script>
 
I can see this part is having problem.
[tt]
<form name="update_subcon_ratings_records" method="Get" action=[red]"update_subcon_ratings_records.asp"[/red]>
<input type=hidden name="frmNAME" value="[red]<%=[/red]insNAME[red]%>[/red]">
<input type=hidden name="frmYEAR" value="[red]<%=[/red]insYEAR[red]%>[/red]">
<input type=hidden name="frmRATING" value="[red]<%=[/red]insRATING[red]%>[/red]">
</form>

<script language="VBScript">
returnvalue=MsgBox("Records already exist in Database!"& vbCrLf &"Do you want to overwrite the records?",36,"Alert")

if returnvalue=6 then
'window.location="update_subcon_ratings_records.asp"
[red]document.update_subcon_ratings_records.submit()[/red]
else
MsgBox "Records NOT inserted",16,"Alert"
history.go(-1)
end if
</script>
[/tt]
I have not read farther. Just a note that make sure though you use the correct method (get) in the form to submit to the page update_subcon_ratings_records.asp in which you are not using request.form.

Also you have the asp forum stand-ready to help you as well.
 
If the following code block is the "2nd script", I think it is, then you have to use method="post" with the corresponding line in my above revision be read like this.
[tt]
<form name="update_subcon_ratings_records" method="[blue]Post[/blue]" action="update_subcon_ratings_records.asp">
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top