Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2004, 02:25 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default 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


 
Old June 3rd, 2004, 04:39 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

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

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


Om Prakash
 
Old June 3rd, 2004, 04:57 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

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


 
Old June 3rd, 2004, 05:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

what is there in line 47?

_________________________
-Vijay G
Strive for Perfection
 
Old June 3rd, 2004, 05:07 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

this is the line no 47
objCmd.Execute intaffectedRec


 
Old June 3rd, 2004, 05:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Strive for Perfection
 
Old June 3rd, 2004, 05:15 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

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

 
Old June 3rd, 2004, 05:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Strive for Perfection
 
Old June 3rd, 2004, 05:32 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

yea it going fine now thanks the problem is i_user_machine account


 
Old June 3rd, 2004, 05:33 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Worked on ASP 2005 but new to VB 2005 akhilhp Visual Basic 2005 Basics 0 May 18th, 2007 12:37 AM
trigger to insert current date on insert kev_79 SQL Server 2000 3 January 23rd, 2006 05:58 PM
ok it worked gilgalbiblewheel Classic ASP Basics 1 January 5th, 2006 10:32 PM
Where Not In Insert Stuart Stalker SQL Server 2000 3 September 21st, 2005 07:06 AM
Insert into jemacc SQL Server 2000 2 March 31st, 2004 08:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.