dbertanjoli
Registered User.
- Local time
- Today, 00:31
- Joined
- Sep 22, 2000
- Messages
- 102
Hello experts,
I am trying to figure out how to send data from my webform into two access tables (tables have a relationship, linked by idname).
This is my code and I can't figure out how to pass idname into my table2.
<%
' Declaring variables
Dim name, age, dateDB, QuestionOne, data_source, con, conOne, sql_insert, sql_insertOne
' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then
string = " "
End If
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
name = ChkString(Request.Form("name"))
age = ChkString(Request.Form("age"))
dateDB = ChkString(Request.Form("dateDB"))
QuestionOne = ChkString(Request.Form("QuestionOne"))
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("form.mdb")
SQL = "insert into users (name, age, dateDB) values ('" & name & "', '" & age & "', '" & dateDB & "')"
Conn.Execute(SQL)
SQL = "insert into Diagnosis (QuestionOne) values ('" & _ QuestionOne & "')"
Conn.Execute(SQL)
Conn.Close
Set Conn = Nothing
Response.Write "All records were successfully entered into the database."
%>
Currently I am receiving the following error message:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'users'.
/2000040101/form_ac.asp, line 34
Many thanks,
Debbie
I am trying to figure out how to send data from my webform into two access tables (tables have a relationship, linked by idname).
This is my code and I can't figure out how to pass idname into my table2.
<%
' Declaring variables
Dim name, age, dateDB, QuestionOne, data_source, con, conOne, sql_insert, sql_insertOne
' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then
string = " "
End If
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
name = ChkString(Request.Form("name"))
age = ChkString(Request.Form("age"))
dateDB = ChkString(Request.Form("dateDB"))
QuestionOne = ChkString(Request.Form("QuestionOne"))
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("form.mdb")
SQL = "insert into users (name, age, dateDB) values ('" & name & "', '" & age & "', '" & dateDB & "')"
Conn.Execute(SQL)
SQL = "insert into Diagnosis (QuestionOne) values ('" & _ QuestionOne & "')"
Conn.Execute(SQL)
Conn.Close
Set Conn = Nothing
Response.Write "All records were successfully entered into the database."
%>
Currently I am receiving the following error message:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'users'.
/2000040101/form_ac.asp, line 34
Many thanks,
Debbie