need help to solve Jet Database engine error

R

riyaz

hi all,

i am just triying to post data to MS -access table from normal textarea in
asp page,

here is my code:

<%
Dim cn1,rs1,sql1
Dim sResult,sResult1,sResult2


Set cn1 = Server.CreateObject("ADODB.Connection")
Set rs1 = Server.CreateObject("ADODB.Recordset")


cn1.Provider = "MicroSoft.jet.OLEDB.4.0"
cn1.Open "C:\Inetpub\wwwroot\webap\test.mdb"

sResult=Request.Form("s1") //-- data from textarea1
sResult1=Request.Form("s2")//-- data from textarea2
sResult2=Request.Form("s3")//--data from textarea3

if Request.Form("Submit1")= "Submit" then
if c <> 1 then
sql1 = "insert into feb
Values('"&sResult&"','"&sResult1&"','"&sResult2&"')"
rs1.Open sql1,cn1,3,3//--line 82
else
end if
end if
%>
<%
if Request.Form("Submit1") = "Submit" then
if c <> 1 then
Response.Redirect "posted.htm"
end if
else
end if
%>


error is:

Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
/webap/insert.asp, line 82

plz help me to modify my code


best regards
Niyaz
 
E

e.pricecut

You're trying to use SQL expression but with recordset - no go. Stick
either with recodset or connection object.

<%
Set cn1=Server.CreateObject("ADODB.Connection")
cn1.open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\webap\test.mdb"

sResult=Replace(Request.Form("s1"), "'","''")
sResult1=Replace(Request.Form("s2"), "'","''")
sResult2=Replace(Request.Form("s3"), "'","''")

if Request.Form("Submit1")="Submit" then
sql1="insert into feb
Values('"&sResult&"','"&sResult1&"','"&sResult2&"')"
cn1.Execute(sql1)
end if
cn1.close
Set cn1=Nothing
%>
 
R

riyaz

i have modified according to your code, but still
i am getting the same error..

i dont know whts is the actual problem n my side..

best regards
niyaz
 
E

e.pricecut

Actually I used the same query string from your code..
It should be revised to reflect the field names from table..

sql1="insert into feb(field1, field2, field3)
Values('"&sResult&"','"&sResult1&"','"&sResult2&"')"

where field1 - 3 are the actual field names from the table where record
is inserted..
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top