Could somebody please convert the attached code in asp vbscript to asp.net.
I would be very grateful.
James
<%
'Get the parameters posted from the test'
total=Request.form("total")
correct=Request.form("correct")
accuracy=Request.form("accuracy")
name=Request.form("name")
email=Request.form("email")
'Validate that this is actually from a Captivate test'
if total="" Or correct="" Or accuracy="" Or name="" Or email="" then
Response.Write "<html>"
Response.Write "<head><title>Failure</title></head>"
Response.Write "<body>"
Response.Write "STATUS=500"
Response.Write "<br>"
Response.Write "Could not parse test results due to a parameter error."
Response.Write "</body></html>"
else
'Write the results to an access database'
' First let us create Connection and Recordset objects'
' Connection string’
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & "DATA SOURCE=" & Server.MapPath("/fpdb/quizresults.mdb")
Set Rs = Server.CreateObject("ADODB.RecordSet")
' Now, create the SQL statement'
sSQL = "INSERT INTO captivate(total, correct, accuracy, name, email) VALUES ( " & total & ", " & correct & ", " & accuracy & ", '" & name & "', '" & email & "')"
' Execute the SQL statement, and set the recordset object'
' to the result of this execution. We obtain the resulting'
' records in Rs object'
Set Rs = Conn.Execute(sSQL)
' Close the Recordset object and destroy it'
Set Rs = Nothing
' You might want to release the resources for connection object, '
' unless you want to use the same connection again in the later code'
Conn.Close
Set Conn = Nothing
'The response is optional, it is good for debugging'
Response.Write "<html>"
Response.Write "<head><title>Success</title></head>"
Response.Write "<body>"
Response.Write "STATUS=200"
Response.Write "<br>"
Response.Write(sSQL)
Response.Write "<br>"
Response.Write "Success."
Response.Write "</body></html>"
end if
%>
<html>
<head>
<title>Email Results</title>
<meta http-equiv="refresh" content="4;URL=javascript:window.close();">
</head>
<body><br />
Thank you for taking your final quiz. <br />
This window will close automatically.
asante_za
Member
16 Points
113 Posts
Convert asp code to asp.net (vb) or asp.net (C#)
Dec 06, 2009 12:13 PM|LINK
Hi
Could somebody please convert the attached code in asp vbscript to asp.net.
I would be very grateful.
James
<% 'Get the parameters posted from the test' total=Request.form("total") correct=Request.form("correct") accuracy=Request.form("accuracy") name=Request.form("name") email=Request.form("email") 'Validate that this is actually from a Captivate test' if total="" Or correct="" Or accuracy="" Or name="" Or email="" then Response.Write "<html>" Response.Write "<head><title>Failure</title></head>" Response.Write "<body>" Response.Write "STATUS=500" Response.Write "<br>" Response.Write "Could not parse test results due to a parameter error." Response.Write "</body></html>" else 'Write the results to an access database' ' First let us create Connection and Recordset objects' ' Connection string’ set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & "DATA SOURCE=" & Server.MapPath("/fpdb/quizresults.mdb") Set Rs = Server.CreateObject("ADODB.RecordSet") ' Now, create the SQL statement' sSQL = "INSERT INTO captivate(total, correct, accuracy, name, email) VALUES ( " & total & ", " & correct & ", " & accuracy & ", '" & name & "', '" & email & "')" ' Execute the SQL statement, and set the recordset object' ' to the result of this execution. We obtain the resulting' ' records in Rs object' Set Rs = Conn.Execute(sSQL) ' Close the Recordset object and destroy it' Set Rs = Nothing ' You might want to release the resources for connection object, ' ' unless you want to use the same connection again in the later code' Conn.Close Set Conn = Nothing 'The response is optional, it is good for debugging' Response.Write "<html>" Response.Write "<head><title>Success</title></head>" Response.Write "<body>" Response.Write "STATUS=200" Response.Write "<br>" Response.Write(sSQL) Response.Write "<br>" Response.Write "Success." Response.Write "</body></html>" end if %> <html> <head> <title>Email Results</title> <meta http-equiv="refresh" content="4;URL=javascript:window.close();"> </head> <body><br /> Thank you for taking your final quiz. <br /> This window will close automatically.vinz
All-Star
127011 Points
17934 Posts
MVP
Re: Convert asp code to asp.net (vb) or asp.net (C#)
Dec 07, 2009 03:19 AM|LINK
Why not start learning ASP.NET instead?
http://www.asp.net/learn/
MessageBox Controls for WebForms | Blog | Twitter | Linkedin