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 September 12th, 2003, 03:51 AM
CW CW is offline
Authorized User
 
Join Date: Sep 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default UPDATING problem

This is the updating asp script.

<% 'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsUpdateEntry 'Holds the recordset for the record to be updated
Dim strSQL 'Holds the SQL query to query the database
Dim getRecordID 'Holds the record number to be updated
'Read in the record number to be updated
getRecordID= CLng(Request.Form("ID_no"))
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using
'DSN connection
adoCon.Open "DSN=Guest"
'Create an ADO recordset object
Set rsUpdate = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblName.* FROM tblStudents WHERE ID_no=" & getRecordID
'Set the cursor type we are using so we can navigate through
'the recordset
rsUpdate.CursorType = 2
'Set the lock type so that the record is locked by ADO when it
'is updated
rsUpdate.LockType = 3
'Open the recordset with the SQL query
rsUpdate.Open strSQL, adoCon
'Update the record in the recordset
rsUpdate.Fields("FName") = Request.Form("fname")
rsUpdate.Fields("LName") = Request.Form("lname")
'Write the updated recordset to the database
rsUpdate.Update
'Reset server objects
rsUpdate.Close
rsUpdate= Nothing
Set adoCon = Nothing
%>

When i execute this scripts from the update-form, i will get an error wich says:
 Database or Object is Read-Only.

I have checked the Guest database, and it is not read-only.
Permission is OK. Even the option button in the ODBC microsoft access setup is not Read-only.

Could any one help !!!!


Thanks in advance




 
Old September 12th, 2003, 05:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

This line
strSQL = "SELECT tblName.* FROM tblStudents WHERE ID_no=" & getRecordID
looks a bit strange, shouldn't it be
strSQL = "SELECT tblStudents.* FROM tblStudents WHERE ID_no=" & getRecordID
?

I'm curious though, this seems like a long-winded way to do an update. What's wrong with executing a SQL UPDATE statement instead:
Code:
<% 'Dimension variables
Dim adoCon            'Holds the Database Connection Object 
Dim strSQL             'Holds the SQL query to query the database 
Dim getRecordID     'Holds the record number to be updated

'Read in the record number to be updated
getRecordID= CLng(Request.Form("ID_no"))

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using 
'DSN connection
adoCon.Open "DSN=Guest"

'Initialise the strSQL variable with an SQL statement to update the database
strSQL = "UPDATE tblStudents "
strSQL = strSQL & "SET FName = '" & Replace(Request.Form("fname"), "'", "''") & "',"
strSQL = strSQL & "LName = '" & Replace(Request.Form("lname"), "'", "''") & "'"
strSQL = strSQL & " WHERE ID_no=" & getRecordID

'Update the record in the recordset
Const adExecuteNoRecords = 128
adoCon.Execute strSQL, , adExecuteNoRecords

'Reset server objects
adoCon.Close
Set adoCon = Nothing
%>
hth
Phil
 
Old September 12th, 2003, 07:53 AM
Authorized User
 
Join Date: Aug 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don’t believe your problem is code as much as it is Operating System/File system security. I’ve been fighting this same problem with Windows XP and just learned that I needed to give the IUSR_machinename user, NTFS permissions to the folder where my data resides on disk. Which I suspected but couldn’t find the security tab when doing a properties on the folder in question. I just learned that you need to go to Tools | Folder Options | View tab; all the way at the bottom is a ‘Use simple file sharing option’. Uncheck this and you get your Security tab while doing a properties on a folder. Now you can grant IUSR_machinename user NTFS (minimum: Read & Execute, List Folder Contents, Read and Write) permission to the location of the database files and life should be good.
 
Old September 23rd, 2003, 04:25 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Tried this?

rsUpdate.Open strSQL, adoCon, 3, 3






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in updating records naveed77 Beginning VB 6 14 January 26th, 2007 05:56 AM
Problem updating query sinner Classic ASP Databases 0 January 29th, 2006 02:51 PM
problem in updating in dataset vohra_vikas2004 ADO.NET 1 June 28th, 2005 05:26 AM
problem updating using datagrid bananaking ASP.NET 1.0 and 1.1 Basics 7 May 13th, 2005 07:32 AM
problem in updating datagrid noor ASP.NET 1.0 and 1.1 Basics 1 April 26th, 2005 03:10 AM





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