Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1763
Number of posts: 4498

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Access database and SQL insert query Posted by Ribbleton on 14 Mar 2006 at 11:10 AM
I have a include file called databaseconnection.asp

'databaseconnection.asp file
<% 
Dim adoCon         				
Dim strSQL          		

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

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};" &_
"Dbq=C:\Inetpub\wwwroot\EL3888NetApplications\database.mdb; "
%>


 ' this is a screen called buy.asp
<%@ Language="VBScript" %>
<!-- #include FILE="DatabaseConnection.asp"-->
<HTML>
	<HEAD>
	
	<%	
	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")
	%>
	</HEAD>
</HTML>

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.
Report
Re: Access database and SQL insert query Posted by weapon__x on 14 Mar 2006 at 10:52 PM
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
Report
Re: Access database and SQL insert query Posted by weapon__x on 19 Mar 2006 at 9:11 PM
: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

Report
Re: Access database and SQL insert query Posted by Manning on 20 Apr 2006 at 11:13 AM
: I have a include file called databaseconnection.asp
:
:
'databaseconnection.asp file
: <% 
: Dim adoCon         				
: Dim strSQL          		
: 
: Set adoCon = Server.CreateObject("ADODB.Connection")
: 
: adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};" &_
: "Dbq=C:\Inetpub\wwwroot\EL3888NetApplications\database.mdb; "
: %>
: 

:
:
 ' this is a screen called buy.asp
: <%@ Language="VBScript" %>
: <!-- #include FILE="DatabaseConnection.asp"-->
: <HTML>
: 	<HEAD>
: 	
: 	<%	
: 	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")
: 	%>
: 	</HEAD>
: </HTML>
: 

: 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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.