www.webdeveloper.com
Results 1 to 2 of 2

Thread: Inserting multiple form fields in one database field

  1. #1
    Join Date
    Feb 2008
    Posts
    23

    Inserting multiple form fields in one database field

    Hello,

    Below you will see I have the variable "attend" which is calling three different fields from a form.

    Code:
    attend =  (request("attend_name") & request("attend_title") & request("attend_email") )
    I was wondering if anyone knows how to insert the three fields data together into the same field in the database once submitted. thanks for your help!

    Example:
    Code:
    sql = sql & "'" & Replace(Request.Form("attend"), "'", "") & "')"

    FULL CODE

    Code:
    attend =  (request("attend_name") & request("attend_title") & request("attend_email") )
    
    
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open "d:/w-request.mdb"
    
    
    sql = "INSERT INTO Meeting (contact_name,contact_title,contact_org,contact_phone,contact_fax,contact_web,contact_email,purpose,question,contact_date,datealt,attend)"
    sql = sql & " VALUES "
    sql = sql & "('" & Replace(Request.Form("Contact_Name"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Contact_Title"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Contact_Org"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Contact_Phone"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Contact_Fax"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Contact_Web"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Contact_Email"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Purpose"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Question"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("Contact_Date"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("DateAlt"), "'", "") & "',"
    sql = sql & "'" & Replace(Request.Form("attend"), "'", "") & "')"
    on error resume next

  2. #2
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    You are defining your variable based on the three form fields but you never call that variable in your SQL statement.

    I am assuming the form field attent does not exist n your form collection

    Replace
    Request.Form("attend")
    with
    attend

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles