Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 3rd, 2004, 02:25 AM
Authorized User
 
Join Date: Feb 2004
Location: Karachi, , Pakistan.
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


Reply With Quote
  #2 (permalink)  
Old June 3rd, 2004, 04:39 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
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
Reply With Quote
  #3 (permalink)  
Old June 3rd, 2004, 04:57 AM
Authorized User
 
Join Date: Feb 2004
Location: Karachi, , Pakistan.
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


Reply With Quote
  #4 (permalink)  
Old June 3rd, 2004, 05:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what is there in line 47?

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
  #5 (permalink)  
Old June 3rd, 2004, 05:07 AM
Authorized User
 
Join Date: Feb 2004
Location: Karachi, , Pakistan.
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


Reply With Quote
  #6 (permalink)  
Old June 3rd, 2004, 05:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #7 (permalink)  
Old June 3rd, 2004, 05:15 AM
Authorized User
 
Join Date: Feb 2004
Location: Karachi, , Pakistan.
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")

Reply With Quote
  #8 (permalink)  
Old June 3rd, 2004, 05:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #9 (permalink)  
Old June 3rd, 2004, 05:32 AM
Authorized User
 
Join Date: Feb 2004
Location: Karachi, , Pakistan.
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


Reply With Quote
  #10 (permalink)  
Old June 3rd, 2004, 05:33 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 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.
Reply With Quote
Reply


Thread Tools
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04:58 PM
ok it worked gilgalbiblewheel Classic ASP Basics 1 January 5th, 2006 09: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 07:31 AM



All times are GMT -4. The time now is 03:23 AM.


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