p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Classic ASP Databases (http://p2p.wrox.com/classic-asp-databases-62/)
-   -   insert into not worked (http://p2p.wrox.com/classic-asp-databases/13703-insert-into-not-worked.html)

knight June 3rd, 2004 02:25 AM

insert into not worked
 
i write the following code



<%if session("granted") = false then
        response.redirect("unauth.htm")
else
'on error resume next
dim rs1,rs2
code=request.Form("code")
rname=request.Form("name")
desc=request.Form("desc")
s1=request.Form("size[0]")
s2=request.Form("size[1]")
s3=request.Form("size[2]")
s4=request.Form("size[3]")
s5=request.Form("size[4]")
s6=request.Form("size[5]")
s7=request.Form("size[6]")
s8=request.Form("size[7]")
price=request.Form("price")
karat=request.Form("karat")
opqty=request.Form("opqty")

set rs1 = server.CreateObject("Adodb.Recordset")
rs1.open ("Select * from tblrings where name='"&ring_name&"'"), conn,1,3
if rs1.eof<>true and rs1.bof<>true then
response.Redirect("add_ring.asp?check=1")
rs1.close
set rs1=nothing

else

'set rs2 = server.CreateObject("Adodb.Recordset")
dim objCmd,intaffectedRec
Set objCmd = Server.CreateObject ("ADODB.Command")

objCmd.ActiveConnection = conn
objCmd.CommandText = "insert into tblRings values('" & ring_code & "', '" & ring_name & "', '" & desc & "'"
objCmd.CommandType = adCmdText
objCmd.Execute intaffectedRec
Response.Write("Number of Records affceted: & intaffectedRec & ")
Set objCmd = Nothing
'response.write rsSQL
response.Redirect("saveimage.asp")
'response.Redirect("add_product.asp?check=2")
end if
conn.close
end if%>

--------------------------
error is shown

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/jewler/admin/save_ring.asp, line 39


Browser Type:
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

Page:
POST 79 bytes to /jewler/admin/save_ring.asp

POST Data:
ringcode=ssdsds&ringname=sdddds&desc=sdsddsdsds&pr ice=&karat=&opqty=&Submit=Add

Time:
Thursday, June 03, 2004, 11:44:25 AM


More information:
Microsoft Support
please help me



om_prakash June 3rd, 2004 04:39 AM

check the objCmd.CommandText statement, brackets are not completed.

Should be :
objCmd.CommandText = "insert into tblRings values('" & ring_code & "', '" & ring_name & "', '" & desc & "')"


Om Prakash

knight June 3rd, 2004 04:57 AM

now error is shown Error Type:
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
/jewler/admin/test.asp, line 47
whats wrong



happygv June 3rd, 2004 05:04 AM

what is there in line 47?

_________________________
-Vijay G
[8]Strive for Perfection[8]

knight June 3rd, 2004 05:07 AM

this is the line no 47
objCmd.Execute intaffectedRec



happygv June 3rd, 2004 05:11 AM

You might want to check this?
http://support.microsoft.com/default...;en-us;q175168

Also can you post the connection string that you use?

Cheers!

_________________________
-Vijay G
[8]Strive for Perfection[8]

knight June 3rd, 2004 05:15 AM

yea my connection string is
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "& server.MapPath("./_db/online_db.mdb")


happygv June 3rd, 2004 05:22 AM

Ok, I dont think your connectionstring could cause problem, it looks fine.

1) The reason for this (besides occasional mis-designed SQL statement) is, that not all necessary permissions are set. User IUSR_<machine name> has to have permissions:

a) For the directory the Access database resides in (right-click on the directory in Explorer, select "Properties," "Security", if the "Security" Tab is missing, go into "Tools," "Folder Options," and deactivate "Simple File sharing")

b) For the Access database itself ("Tools", "Security", "User and Group Permissions")

2)There are several things that may cause this ODBC error. Many of the possible reasons are listed below.

* The permissions that are set on the directory the database is in. IUSR privileges must be set to "read/write".

* The permissions on the database itself does not have full read/write privileges in effect.

* This error can also occur when the database is located outside of the inetpub/wwwroot directory. Though the information is still able to be viewed and searched, it cannot be updated unless it is in the wwwroot directory.

Hope that helps.
Cheers!

_________________________
-Vijay G
[8]Strive for Perfection[8]

knight June 3rd, 2004 05:32 AM

yea it going fine now thanks the problem is i_user_machine account



Imar June 3rd, 2004 05:33 AM

Hi Vijay G,

I agree with all the information you provided in your posts in this thread, except for your last remark:
Quote:

quote:* This error can also occur when the database is located outside of the inetpub/wwwroot directory. Though the information is still able to be viewed and searched, it cannot be updated unless it is in the wwwroot directory.
This is not true. I fact, it's often recommended to store the database outside the web scope, in C:\Databases for example, to prevent the database from being downloaded. If you store the database within your webroot, like C:\inetpub\wwwroot\Databases, it can be downloaded using http, for example: http://YourServerName/Databases/YourDatabase.mdb

You can prevent that from happening by setting additional security settings on the file and folder (using Integrated Security, in combination with NTFS security), but placing the database outside the web root is often much easier.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.


All times are GMT -4. The time now is 04:11 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.