I have problems writing data from my webform to two linked tables. I am quiet sure that my insert into syntax is not correct. Please take a look if you have a moment, if not I understand:
[code=asp]
<%
' 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(strin g)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
name = ChkString(Reque st.Form("name") )
age = ChkString(Reque st.Form("age"))
dateDB = ChkString(Reque st.Form("dateDB "))
QuestionOne = ChkString(Reque st.Form("Questi onOne"))
data_source = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & _
Server.MapPath( "form.mdb")
sql_insert = "insert into users (name, age, dateDB) values ('" & _
name & "', '" & age & "', '" & dateDB & "'); insert into Diagnosis (QuestionOne) values ('" & _ QuestionOne & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateOb ject("ADODB.Con nection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
Response.Write "All records were successfully entered into the database."
%>[/code]
[code=asp]
<%
' 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(strin g)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
name = ChkString(Reque st.Form("name") )
age = ChkString(Reque st.Form("age"))
dateDB = ChkString(Reque st.Form("dateDB "))
QuestionOne = ChkString(Reque st.Form("Questi onOne"))
data_source = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & _
Server.MapPath( "form.mdb")
sql_insert = "insert into users (name, age, dateDB) values ('" & _
name & "', '" & age & "', '" & dateDB & "'); insert into Diagnosis (QuestionOne) values ('" & _ QuestionOne & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateOb ject("ADODB.Con nection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
Response.Write "All records were successfully entered into the database."
%>[/code]
Comment