Insert into msAccess problems

Discussion in 'ASP General' started by chumley, Feb 25, 2010.

  1. chumley

    chumley Guest

    I'm using Access dbase for a simple insertion, when i post from my
    form page into my insertion script, i get error at the
    StrConnz.Execute (StrSql) command line of the query needs to be
    updateable type:
    Microsoft JET Database Engine error '80004005'
    Operation must use an updateable query.
    /providerform/fo-add.asp, line 25

    '''''''''''''''''
    <%@ LANGUAGE="VBSCRIPT"%>
    <%Response.Buffer = True%>
    <%
    dim dsn,StrConnz
    dsn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
    Server.MapPath("fo1.mdb")
    Set StrConnz = Server.CreateObject("ADODB.Connection")
    StrConnz.Open dsn

    dim strSql
    strSql = "insert into tblMain
    (LastName,FirstName,fund,Industry,Company) values ('"
    strSql = StrSql & replace(Request.Form("LastName"),"'","''") & "', '"
    strSql = StrSql & Request.Form("FirstName") & "', '"
    strSql = StrSql & Request.Form("fund") & "','"
    strSql = StrSql & Request.Form("Industry") & "', '"
    strSql = StrSql & Request.Form("Company") & "')"
    StrConnz.Execute (StrSql) %>

    not sure why as i am connecting properly to dbase

    ???
    chumley
     
    chumley, Feb 25, 2010
    #1
    1. Advertising

  2. chumley

    Bob Barrows Guest

    chumley wrote:
    > I'm using Access dbase for a simple insertion, when i post from my
    > form page into my insertion script, i get error at the
    > StrConnz.Execute (StrSql) command line of the query needs to be
    > updateable type:
    > Microsoft JET Database Engine error '80004005'
    > Operation must use an updateable query.
    > /providerform/fo-add.asp, line 25
    >
    > '''''''''''''''''
    > <%@ LANGUAGE="VBSCRIPT"%>
    > <%Response.Buffer = True%>
    > <%
    > dim dsn,StrConnz
    > dsn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
    > Server.MapPath("fo1.mdb")
    > Set StrConnz = Server.CreateObject("ADODB.Connection")
    > StrConnz.Open dsn
    >
    > dim strSql
    > strSql = "insert into tblMain
    > (LastName,FirstName,fund,Industry,Company) values ('"
    > strSql = StrSql & replace(Request.Form("LastName"),"'","''") & "', '"
    > strSql = StrSql & Request.Form("FirstName") & "', '"
    > strSql = StrSql & Request.Form("fund") & "','"
    > strSql = StrSql & Request.Form("Industry") & "', '"
    > strSql = StrSql & Request.Form("Company") & "')"
    > StrConnz.Execute (StrSql) %>
    >

    http://www.aspfaq.com/show.asp?id=2062

    Further points to consider:
    Your use of dynamic sql is leaving you vulnerable to hackers using sql
    injection:
    http://mvp.unixwiz.net/techtips/sql-injection.html
    http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23

    See here for a better, more secure way to execute your queries by using
    parameter markers:
    http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/72e36562fee7804e

    Personally, I prefer using stored procedures, or saved parameter queries
    as
    they are known in Access:

    Access:
    http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=

    http://groups.google.com/groups?hl=...=1&selm=



    --
    Microsoft MVP - ASP/ASP.NET - 2004-2007
    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, Feb 25, 2010
    #2
    1. Advertising

  3. chumley

    Dan Guest

    "chumley" <> wrote in message
    news:...
    > I'm using Access dbase for a simple insertion, when i post from my
    > form page into my insertion script, i get error at the
    > StrConnz.Execute (StrSql) command line of the query needs to be
    > updateable type:
    > Microsoft JET Database Engine error '80004005'
    > Operation must use an updateable query.
    > /providerform/fo-add.asp, line 25
    >
    > '''''''''''''''''
    > <%@ LANGUAGE="VBSCRIPT"%>
    > <%Response.Buffer = True%>
    > <%
    > dim dsn,StrConnz
    > dsn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
    > Server.MapPath("fo1.mdb")
    > Set StrConnz = Server.CreateObject("ADODB.Connection")
    > StrConnz.Open dsn
    >
    > dim strSql
    > strSql = "insert into tblMain
    > (LastName,FirstName,fund,Industry,Company) values ('"
    > strSql = StrSql & replace(Request.Form("LastName"),"'","''") & "', '"
    > strSql = StrSql & Request.Form("FirstName") & "', '"
    > strSql = StrSql & Request.Form("fund") & "','"
    > strSql = StrSql & Request.Form("Industry") & "', '"
    > strSql = StrSql & Request.Form("Company") & "')"
    > StrConnz.Execute (StrSql) %>
    >
    > not sure why as i am connecting properly to dbase
    >
    > ???
    > chumley


    As well as Bob's recommendation of using parameterised queries, also check
    that the ASP application has write permission to the folder that the mdb
    file is located in (if not then the database is opened as read only. Is
    tblMain a table, or a query? If it's a query, it will be unupdateable if any
    of the tables involved don't have a primary key, or if you are using any
    joins other than INNER.

    --
    Dan
     
    Dan, Feb 25, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timothy
    Replies:
    1
    Views:
    853
    rajasekhar
    Jan 2, 2004
  2. cory
    Replies:
    2
    Views:
    381
    William LaMartin
    Jan 7, 2004
  3. Annick Van Hoof

    MSAccess problems

    Annick Van Hoof, Jul 8, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    551
  4. Siegfried Heintze
    Replies:
    1
    Views:
    796
    Paul Henderson
    Apr 15, 2006
  5. Sergio del Amo
    Replies:
    4
    Views:
    265
Loading...

Share This Page