Hello,
I have a questinarrie webform I use INSERT statement(s) to insert a new record in the User and Questions tables and then (HERE IS MY PROBLEM) I need to update my junction table (QuestionScores - has two fields; questionid and scoreID).
What should be a statement to update my junction table?
This is my code except updates to junction table:
I have a questinarrie webform I use INSERT statement(s) to insert a new record in the User and Questions tables and then (HERE IS MY PROBLEM) I need to update my junction table (QuestionScores - has two fields; questionid and scoreID).
What should be a statement to update my junction table?
This is my code except updates to junction table:
Code:
<%
' Declaring variables
Dim tmpFullName, tmpAge, tmpDateDB, tmpMedicalRecord, tmpExamOne, tmpExamTwo, Question1, Question2, Question3, data_source, conn, conOne, sql_insert
' Receiving values from Form
tmpName = (Request.Form("FullName"))
tmpAge = (Request.Form("age"))
tmpDateDB = (Request.Form("dateDB"))
tmpMedicalRecord = (Request.Form("MedicalRecord"))
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.connectionstring = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" _
& Server.Mappath("Questions.mdb") & ";"
objConn.Open
SQLstmt = "INSERT INTO users (txtFullName, intAge, txtDateDB, intMedicalRecord)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "'" & tmpName & "',"
SQLstmt = SQLstmt & "'" & tmpAge & "',"
SQLstmt = SQLstmt & "'" & tmpDateDB & "',"
SQLstmt = SQLstmt & "'" & tmpMedicalRecord & "'"
SQLstmt = SQLstmt & ")"
SET RS = objConn.Execute(SQLstmt)
SQLstmt = "SELECT MAX(idUsers) as MaxUserId FROM Users;"
Set RS=objConn.Execute(SQLstmt)
thisRecord = rs("MaxUserId")
For x = 0 to 30
tmpAnswer = Request.Form("Question" & x)
SQLstmt = "INSERT INTO Questions (idUser, QuestionNumber, QuestionAnswer)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "'" & thisRecord & "',"
SQLstmt = SQLstmt & "'" & x & "',"
SQLstmt = SQLstmt & "'" & tmpAnswer & "'"
SQLstmt = SQLstmt & ")"
SET RS = objConn.Execute(SQLstmt)
next
objConn.Close
Set objConn = Nothing
Response.Write "All records were successfully entered into the database."
%>
Comment