If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Unable to use Query in my ASP application

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-18-04, 02:21
Dniz Dniz is offline
Registered User
 
Join Date: Oct 2004
Posts: 26
Question Unable to use Query in my ASP application

Hi,

I have just picked up ASP a month ago and i am learning ASP fast with additional knowledge in C programming, few knowledge in query language and html. However, I receive the same error message whenever I use query language to modify my database , as in using INSERT, UPDATE and DELETE. I attach the add data html and code along with this thread. The database only consist of a table call CDs that has 3 fields of data, which are artist, title and format. Hope someone can give me a hand here. Thanks!

Error Message:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.


Addcds.htm

<HTML>
<FORM METHOD="GET" ACTION="addcds.asp">
<H3>Add CD to Database</H3>
<B>Artist</B><BR>
<INPUT TYPE="TEXT" NAME="artist" MAXLENGTH="50"><P>
<B>Title</B><BR>
<INPUT TYPE="TEXT" NAME="title" MAXLENGTH="50"><P>
<B>Format</B><BR>
<INPUT TYPE="RADIO" NAME="format" VALUE="CDA" CHECKED> Album<BR>
<INPUT TYPE="RADIO" NAME="format" VALUE="CDS"> Single<P>
<INPUT TYPE="SUBMIT" VALUE="Add to database"><P>
<INPUT TYPE="RESET" VALUE="Clear">
</FORM>
</BODY>
</HMTL>


Addcds.asp

<%
artist=Request("artist")
title=Request("title")
format=Request("format")
Query = "INSERT INTO CDs (artist,title,format) VALUES ("
Query = Query & "'" & artist & "','" & title & "','" & format & "')"
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "records"
Set RSlist = Server.CreateObject("ADODB.recordset")
RSlist.Open Query,DataConn,3
%>
<HTML>
<BODY>
<H3>CD Added To Collection Database</H3>
<HR>
<SMALL><%=Query%></SMALL>
</BODY>
</HTML>

Last edited by Dniz; 12-18-04 at 02:33.
Reply With Quote
  #2 (permalink)  
Old 12-19-04, 20:12
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
The quick and simple answer is that the user that is running IIS does not have write access to the database....
Reply With Quote
  #3 (permalink)  
Old 12-20-04, 22:12
Dniz Dniz is offline
Registered User
 
Join Date: Oct 2004
Posts: 26
How can I access to my database? Is there any extra configuration in the ODBC? I had been successfully read from the database anyway, using the select function. I assumed it's a backward process to modify the database. Have I got the idea wrong?
Reply With Quote
  #4 (permalink)  
Old 12-29-04, 18:58
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Perhaps this might help:

Why do I get database-related 80004005 errors?
http://www.aspfaq.com/show.asp?id=2009
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #5 (permalink)  
Old 01-09-05, 22:10
Dniz Dniz is offline
Registered User
 
Join Date: Oct 2004
Posts: 26
Would you recommend me to format my PC? I tried install and unsinstalled IIS in my computer a few times already. Also have all the permission configured. I did the same for other computer but I can used the IIS smoothly without any problem.
Reply With Quote
  #6 (permalink)  
Old 01-14-05, 10:43
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
For the INSERT statement, you need to use Execute(sql) method.

<%
Query = "INSERT INTO CDs (artist,title,format) VALUES ("
Query = Query & "'" & artist & "','" & title & "','" & format & "')"
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "records"
DataConn.Execute(Query)
%>
Reply With Quote
  #7 (permalink)  
Old 01-17-05, 02:10
Dniz Dniz is offline
Registered User
 
Join Date: Oct 2004
Posts: 26
Smile

Quote:
Originally Posted by gyuan
For the INSERT statement, you need to use Execute(sql) method.

<%
Query = "INSERT INTO CDs (artist,title,format) VALUES ("
Query = Query & "'" & artist & "','" & title & "','" & format & "')"
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "records"
DataConn.Execute(Query)
%>
I've tried the method. Thanks for your suggestion. Actually, I think the problem is with my computer, not the IIS.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On