Using Microsoft Access with Lectora
May 4, 2007 12:00 AM
Here is what you need to do.* Edited the Post and made a correction. *Create an asp page with the exact code below (copy and paste). I made some changes to your code.Run the page in a browser. If you get the 500 message, then you need to double check your column names to make sure they match exactly those in the database.If you get the 200 message, then you need to ensure the folder directory is correct.As a test, in Title Properties and Additional files, type in the URL where the asp file will reside. E.g. http://www.mycompany.com/asp/sendresults.asp<%@ Language=VBScript %> <% dim adoConn dim rsResult dim strSQL dim sUserID dim sFirstName dim sLastName 'Get the parameters posted from the test' sUserID="test123" sFirstName="Bob" sLastName="Jones" 'Validate that this is actually from a Lectora test' if sUserID="" Or sFirstName="" Or sLastName="" then Response.Write "" Response.Write "Failure " Response.Write "" Response.Write "STATUS=500" Response.Write "
" Response.Write "Could not parse test results due to a parameter error." Response.Write "" else 'Write the results to an access database' ' First let us create Connection and Recordset objects' Set adoConn = Server.CreateObject("ADODB.Connection") Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & "DATA SOURCE=" & Server.MapPath("TestResult.mdb") Set rsResult = Server.CreateObject("ADODB.RecordSet") ' Open the connection to the ODBC source, in this case the Access database' adoConn.Open "Result" ' Now, create the SQL statement' strSQL = "INSERT INTO Result(UserID,FirstName,LastName) VALUES ( '" & sUserID & "', '" & sFirstName & "', '" & sLastName & "')" ' Execute the SQL statement, and set the recordset object' ' to the result of this execution. We obtain the resulting' ' records in Rs object' Set rsResult = Conn.Execute(strSQL) ' Close the Recordset object and destroy it' Set rsResult = Nothing ' You might want to release the resources for connection object, ' ' unless you want to use the same connection again in the later code' adoConn.Close Set adoConn = Nothing 'The response is optional, it is good for debugging' Response.Write "" Response.Write "Success " Response.Write "" Response.Write "STATUS=200" Response.Write "
" Response.Write(sSQL) Response.Write "
" Response.Write "Success." Response.Write "" end if %> Edited By: bruman on 2007-12-4 14:48:34
Discussions have been disabled for this post