Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Why can't I use "INSERT INTO"?

Author  Topic 

Sand
Starting Member

3 Posts

Posted - 2006-04-06 : 04:45:13
I have the following code,

<%@LANGUAGE="VBSCRIPT"; CODEPAGE="1252"%>
<%Option Explicit%>
<%
DIM TITLE,AUTHOR,COAUTHOR,UNIVERSITY,AREA,ABSTRACT,ADD,CON

TITLE = Request.Form("title")
AUTHOR = Request.Form("author")
COAUTHOR = Request.Form("coauthor")
UNIVERSITY = Request.Form("uni")
AREA = Request.Form("area")
ABSTRACT = Request.Form("abstract")

SET CON = Server.CreateObject("ADODB.Connection")
CON.Provider = "Microsoft.Jet.OLEDB.4.0"
CON.Open(Server.MapPath("AbstractDB.mdb"))

ADD = "INSERT INTO Abstract(Title,Author,CoAuthor,University,Area,Abstract) VALUES('"&TITLE&"','"&AUTHOR&"','"&COAUTHOR&"','"&UNIVERSITY&"','"&AREA&"','"&ABSTRACT&"')"
CON.Execute(ADD)

CON.CLOSE
%>


Why is it that I get the following error message?

quote:
Error Type:
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
/Test/Submit.asp, line 122


Why am not allowed to use "INSERT INTO"? Can anybody help me?

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-04-06 : 04:52:12
I dont think its SQL Error, your query seem is correct, check out for the connection string .. i think there can be some problem with the connection ..

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-04-06 : 04:55:19
not sure if insert into is allowed in access...



--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-06 : 05:07:22
See if you used correct connection String
www.ConnectionStrings.com

>>not sure if insert into is allowed in access...
Yes it is allowed


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Sand
Starting Member

3 Posts

Posted - 2006-04-06 : 07:07:27
There are two connection strings that I can use.

"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"

and the other is

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"

As of now I am using the latter as shown below

SET CON = Server.CreateObject("ADODB.Connection")
CON.Provider = "Microsoft.Jet.OLEDB.4.0"
CON.Open(Server.MapPath("AbstractDB.mdb"))


How do I go about using the former connection String. I believe its not "ADODB.Connection" right?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-06 : 09:03:28
The second is correct. Check whether the database is in Read only mode. If so remove it and try

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Sand
Starting Member

3 Posts

Posted - 2006-04-06 : 10:35:30
The database is NOT in ReadOnly mode
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-06 : 10:48:36
Then refer http://www.aspfaq.com/show.asp?id=2062

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -