Appending Records to an Access Database

Results 1 to 2 of 2

Thread: Appending Records to an Access Database

  1. #1
    Join Date
    Dec 1969

    Default Appending Records to an Access Database

    help! i&#039;m simply trying to append a record collected from an html form to an access database, but i keep getting a HTTP 500 - Internal Server Error. I&#039;ve check the MapPath, permissions on the database are set for read, write and execute. i&#039;m frustrated. here&#039;s the code snippet i&#039;m using:<BR><BR> Dim strName<BR> Dim strEmail<BR> Dim strSQL<BR> <BR> strName = Request.Form("txtName")<BR> strEmail = Request.Form("txtEmail")<BR><BR> strFile = server.MapPath("hornets_db.mdb")<BR> strConnect = "DRIVER={MICROSOFT ACCESS DRIVER (*.MDB)};DBQ=" & strFile<BR> <BR> Set cn = server.CreateObject("ADODB.CONNECTION")<BR> Set rs = server.CreateObject("ADODB.RECORDSET")<BR> cn.Open strConnect<BR><BR> strSQL = "INSERT INTO Person (name,email) VALUES (strName, strEmail)"<BR> <BR><BR> set rs = cn.execute(strSQL)<BR><BR>what am i forgetting?<BR><BR>thanks a million. . .

  2. #2
    Join Date
    Dec 1969

    Default variables, quotes, returning records

    Write your strSQL so you can access your variables:<BR>(Include quotes)<BR><BR>strSQL = "INSERT INTO Person (name,email) VALUES (&#039;" & strName & "&#039;, &#039;" & strEmail & "&#039;)"<BR><BR>Execute the command without referencing a recordset<BR>cn.execute strSQL <BR><BR>

Posting Permissions

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