problems adding record to access database

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default problems adding record to access database

    Greetings

    I'm having problems adding records to an access database.
    What I want to do is very simple. Here is my code.

    __CODE_START__

    dim sqlStatement
    sqlStatement="insert into Records(artist,album,format,label,tracks,year)
    values ('Pink Floyd','THE WALL','2CD','EMI',99,1979)"

    dim dataConn
    dim strDatabase, affecetd
    strDatabase="database/musicstore.mdb"
    Set dataConn = Server.CreateObject("ADODB.Connection")
    dataConn.Provider="Microsoft.Jet.OLEDB.4.0"
    dataConn.ConnectionTimeout = 15
    dataConn.CommandTimeout = 30
    dataConn.Open Server.MapPath(strDatabase)

    dataconn.Execute sqlStatement,affected',adCmdText ' <- ERROR OCCURS HERE

    if affecetd = 1 then
    Response.Write("<h1> success </h1>")
    end if

    __CODE_END__

    when I try run the cript I get the error

    __ERROR_START__

    Technical Information (for support personnel)

    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error in INSERT INTO statement.
    /MusicStore/addrecord.asp, line 53


    __ERROR_END__

    If I run the sabe sql statement on "query analyser" of access, it works
    ok (the record is inserted).

    What can be the problem? any ideas?

    Than you very much

    Sérgio Almeida

    Sérgio Almeida Guest

  2. Similar Questions and Discussions

    1. searching for record before adding to database
      Hi all, Im creating a form, and I can now add and save the record. However, since we are concern on duplicate records, I use email as the field...
    2. Trouble with database access: can't edit record, just view it
      Hallo! I use DWMX 6.1 and use ASP VBSCRIPT files to access a MS Access 2000 database. Initially I was able to edit the records. Then I had to add...
    3. FTP Problems with Access Database in MX
      This is driving me crazy! All files will upload without any problems but when it comes to access database, sometimes it will upload fine, but most...
    4. editing record in access database
      I am trying to pull a record into a form and then edit it. (not working to well) Hoping someone can show me a better way than this: <% option...
    5. deleting access database record
      I am trying to write an asp page to delete a record from my access database. I have written the page to display the info but when I select the entry...
  3. #2

    Default problems adding record to access database

    Greetings

    I'm having problems adding records to an access database.
    What I want to do is very simple. Here is my code.

    __CODE_START__

    dim sqlStatement
    sqlStatement="insert into Records(artist,album,format,label,tracks,year)
    values ('Pink Floyd','THE WALL','2CD','EMI',99,1979)"

    dim dataConn
    dim strDatabase, affecetd
    strDatabase="database/musicstore.mdb"
    Set dataConn = Server.CreateObject("ADODB.Connection")
    dataConn.Provider="Microsoft.Jet.OLEDB.4.0"
    dataConn.ConnectionTimeout = 15
    dataConn.CommandTimeout = 30
    dataConn.Open Server.MapPath(strDatabase)

    dataconn.Execute sqlStatement,affected',adCmdText ' <- ERROR OCCURS HERE

    if affecetd = 1 then
    Response.Write("<h1> success </h1>")
    end if

    __CODE_END__

    when I try run the cript I get the error

    __ERROR_START__

    Technical Information (for support personnel)

    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error in INSERT INTO statement.
    /MusicStore/addrecord.asp, line 53


    __ERROR_END__

    If I run the sabe sql statement on "query analyser" of access, it works
    ok (the record is inserted).

    What can be the problem? any ideas?

    Than you very much

    Sérgio Almeida

    Sérgio Almeida Guest

  4. #3

    Default Re: problems adding record to access database

    [url]www.aspfaq.com/5003[/url]

    Ray at work

    "Sérgio Almeida" <sgalmeidaNOSPAM@bragatelNOSPAM.pt> wrote in message
    news:ul$HuHlmDHA.2160@TK2MSFTNGP10.phx.gbl...
    > Greetings
    >
    > I'm having problems adding records to an access database.
    > What I want to do is very simple. Here is my code.
    >

    Ray at Guest

  5. #4

    Default Re: problems adding record to access database

    [url]www.aspfaq.com/5003[/url]

    Ray at work

    "Sérgio Almeida" <sgalmeidaNOSPAM@bragatelNOSPAM.pt> wrote in message
    news:u1T8sHlmDHA.2432@TK2MSFTNGP10.phx.gbl...
    > Greetings
    >
    > I'm having problems adding records to an access database.
    > What I want to do is very simple. Here is my code.
    >

    Ray at Guest

  6. #5

    Default Re: problems adding record to access database

    Sérgio Almeida wrote:
    > Greetings
    >
    > I'm having problems adding records to an access database.
    > What I want to do is very simple. Here is my code.
    >
    > __CODE_START__
    >
    > dim sqlStatement
    > sqlStatement="insert into
    > Records(artist,album,format,label,tracks,year) values ('Pink
    > Floyd','THE WALL','2CD','EMI',99,1979)"
    >
    > dataconn.Execute sqlStatement,affected',adCmdText ' <- ERROR OCCURS
    > Error Type:
    > Microsoft JET Database Engine (0x80040E14)
    > Syntax error in INSERT INTO statement.
    > /MusicStore/addrecord.asp, line 53
    We seem to be having a rash of reserved words problems in the past couple
    days :-)
    "year" (and maybe "format") is a reserved word and should not be used for a
    column name in your database. If you cannot change the name of the field in
    your table, then you will need to surround it with brackets [] when running
    queries containing those names from ADO.

    Here is a list of reserved words which you should avoid when naming objects
    in your database: [url]http://www.aspfaq.com/show.asp?id=2080[/url]

    HTH,
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  7. #6

    Default Re: problems adding record to access database

    Than you Bob.
    That worked, but now I get the error

    Error Type:
    Microsoft JET Database Engine (0x80004005)
    Operation must use an updateable query.
    /MusicStore/addrecord.asp, line 53

    What mus I do?

    Thanks once again.

    Bob Barrows wrote:
    > Sérgio Almeida wrote:
    >
    >>Greetings
    >>
    >>I'm having problems adding records to an access database.
    >>What I want to do is very simple. Here is my code.
    >>
    >>__CODE_START__
    >>
    >>dim sqlStatement
    >>sqlStatement="insert into
    >>Records(artist,album,format,label,tracks,year) values ('Pink
    >>Floyd','THE WALL','2CD','EMI',99,1979)"
    >>
    >>dataconn.Execute sqlStatement,affected',adCmdText ' <- ERROR OCCURS
    >>Error Type:
    >>Microsoft JET Database Engine (0x80040E14)
    >>Syntax error in INSERT INTO statement.
    >>/MusicStore/addrecord.asp, line 53
    >
    >
    > We seem to be having a rash of reserved words problems in the past couple
    > days :-)
    > "year" (and maybe "format") is a reserved word and should not be used for a
    > column name in your database. If you cannot change the name of the field in
    > your table, then you will need to surround it with brackets [] when running
    > queries containing those names from ADO.
    >
    > Here is a list of reserved words which you should avoid when naming objects
    > in your database: [url]http://www.aspfaq.com/show.asp?id=2080[/url]
    >
    > HTH,
    > Bob Barrows
    Sérgio Almeida Guest

  8. #7

    Default Re: problems adding record to access database

    Sérgio Almeida wrote:
    > Than you Bob.
    > That worked, but now I get the error
    >
    > Error Type:
    > Microsoft JET Database Engine (0x80004005)
    > Operation must use an updateable query.
    > /MusicStore/addrecord.asp, line 53
    >
    [url]http://www.aspfaq.com/show.asp?id=2062[/url]

    HTH,
    Bob Barrows



    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows 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