Insert table - ASP and access database

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Insert table - ASP and access database

    Hi,

    I am working towards trying to insert data in to two tables from one form.

    My code won't work so I have simplified everything.

    I currently have a database with two tables. I have cut the tables down to
    three fields each for experimentation. Using the Command dialog box I can
    successfully insert into one of the tables. However I can not insert into the
    second table. I have tried inserting into the second table only and am still
    getting the same error message:

    Microsoft JET Database Engine error '80040e14'
    Syntax error in INSERT INTO statement.
    /abstracts/add4.asp, line 16

    I can only conclude that there is something wrong with my database. The table
    in question has three fields: userid, surname, and firstname.

    The code I'm using to experiment with is pasted below. I have checked and
    rechecked my variables.

    I'm totally stuck. Any ideas? I'm very new to all this....

    THanks

    Jane

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="../Connections/abstracts.asp" -->
    <%

    if(Request.Form("surname") <> "") then Command1__sur = Request.Form("surname")

    %>
    <%

    set Command1 = Server.CreateObject("ADODB.Command")
    Command1.ActiveConnection = MM_abstracts_STRING
    Command1.CommandText = "INSERT INTO user (surname) VALUES ('" +
    Replace(Command1__sur, "'", "''") + "' ) "
    Command1.CommandType = 1
    Command1.CommandTimeout = 0
    Command1.Prepared = true
    Command1.Execute()

    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form name="form1" method="post" action="">
    <p>title
    <input name="title" type="text" id="title">
    </p>
    <p>surname
    <input name="surname" type="text" id="surname">
    </p>
    <p>
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    </body>
    </html>






    enaj Guest

  2. Similar Questions and Discussions

    1. Using Flash to insert data into a MS Access database
      Hi, first of all I am using Flash MX 2004 and have Office 2003. I am trying to use my flash form to insert data into a ms access database but it...
    2. Need Utility to insert a CSV to ACCESS Table
      Hi Guys, first of all thanks for your help. Can someone please help me find a ColdFusion component or custom tag which will allow me to import a...
    3. Insert to Access database error*** Please Help
      When trying to insert into access database with a form created by the standard MX2004 Insert and form wizard, get the "Syntax " error as below. Line...
    4. Login - multi table insert for registrant; subsquent login insert page requests into joined 'Selection' Table
      Question regards insert and updates in sql server for a simple login script that requires registration the first time and only "email address" upon...
    5. How can I create a table in my Access database dynamically in ASP?
      How can I create a table in my Access database dynamically using ASP?
  3. #2

    Default Re: Insert table - ASP and access database

    Try using [user] instead of user. Best to rename the table though. user is a
    reserved word.

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004




    Julian Roberts Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139