Access database and SQL insert query - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Access database and SQL insert query

I have a include file called databaseconnection.asp

[code]'databaseconnection.asp file
<%
Dim adoCon
Dim strSQL

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};" &_
"Dbq=C:InetpubwwwrootEL3888NetApplicationsdatabase.mdb; "
%>
[/code]

[code] ' this is a screen called buy.asp
<%@ Language="VBScript" %>




<%
Dim value
Dim customerId
Dim rsGuestbook

value = Request.QueryString("ProductId")
customerId = 12

strSQL = "INSERT INTO ShoppingBasket Values ('" +Cstr(value)+ "','" +Cstr(customerId)+ "') "

'Response.Write(strSQL)
'strSQL = "SELECT * FROM shoppingbasket"
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
rsGuestbook.Open strSQL, adoCon
Response.Redirect("Search.asp")
%>


[/code]
I though it was somthing todo with the variables being integer but i have fourced them into string cstr().
When i run the insert SQL i can an error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/EL3888NetApplications/Buy.asp, line 19


Anyone got any ideas, SELECT statements work fine.

Comments

  • weapon__xweapon__x Posts: 138Member
    i think thew prob is here:

    strSQL = "INSERT INTO ShoppingBasket Values ('" +Cstr(value)+ "','" +Cstr(customerId)+ "') "


    you moight want to try:

    strSQL = "INSERT INTO ShoppingBasket(fieldname1,fieldname2) Values ('" +Cstr(value)+ "','" +Cstr(customerId)+ "') "

    where
    1. fieldname1= name of field ( of course!) where you want to put the value of your "value" (sounds redundant isn't it?)
    2. fieldname2= name of field ( of course! again!) where you want to put the value of your "customerId"


    baboy... baboy...

    weaps
  • weapon__xweapon__x Posts: 138Member
    :and... i have noticed also some installation of IIS in Win XP. needs to be refreshed... yes i have encountered that same error message before.. what i did was, i only closed the browser window and refreshed/ restart IIS, and viola!!! it works... haven't found out what was wrong though... i'd look into it some other time... maybe anybody out thee knows of this...

    good luck!

    baboy... baboy...

    weaps

  • ManningManning Posts: 1,621Member
    : I have a include file called databaseconnection.asp
    :
    : [code]'databaseconnection.asp file
    : <%
    : Dim adoCon
    : Dim strSQL
    :
    : Set adoCon = Server.CreateObject("ADODB.Connection")
    :
    : adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};" &_
    : "Dbq=C:InetpubwwwrootEL3888NetApplicationsdatabase.mdb; "
    : %>
    : [/code]
    :
    : [code] ' this is a screen called buy.asp
    : <%@ Language="VBScript" %>
    :
    :
    :
    :
    : <%
    : Dim value
    : Dim customerId
    : Dim rsGuestbook
    :
    : value = Request.QueryString("ProductId")
    : customerId = 12
    :
    : strSQL = "INSERT INTO ShoppingBasket Values ('" +Cstr(value)+ "','" +Cstr(customerId)+ "') "
    :
    : 'Response.Write(strSQL)
    : 'strSQL = "SELECT * FROM shoppingbasket"
    : Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
    : rsGuestbook.Open strSQL, adoCon
    : Response.Redirect("Search.asp")
    : %>
    :
    :
    : [/code]
    : I though it was somthing todo with the variables being integer but i have fourced them into string cstr().
    : When i run the insert SQL i can an error:
    :
    : Error Type:
    : Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    : [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
    : /EL3888NetApplications/Buy.asp, line 19
    :
    :
    : Anyone got any ideas, SELECT statements work fine.


    Probably the same problem described here, both INSERTs and UPDATEs will give that error of the .MDB file is not writeable by the IUSR_MachineName account:

    http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=22&MsgID=335097&Setting=A9999F0001
Sign In or Register to comment.