 |
| 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
|
|
|
|

September 15th, 2004, 01:33 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Updating database records in ASP/ADO
Hello, I am having this problem when i try to update an Access 2000 table ("BreakTimes") in ASP based on some input that the user entered in a previous page. I will type the whole code shortly, but first i want to say that i wanted to use objConn.BeginTrans and objConn.CommitTrans and the infamous objRecordset.Update method. Unfortunately i have ran into problems for almost two days now. here is my code:
--------------------------------------------------------------------
Set Conn1 = server.CreateObject("ADODB.Connection")
Set rs1 = Server.CreateObject("ADODB.Recordset")
Conn1.Open "RSSLVLNEW" 'open the database
Conn1.BeginTrans 'Begin a new transaction with the table
rs1.Open SQL,Conn1,3,3
Do until rs1.EOF
rs1.Fields.Item("ShiftStart") = Request(rs1.Fields.Item("DayOfWeek")&"_ShiftStart" )
rs1.Fields.Item("Break1Start") = Request(rs1.Fields.Item("DayofWeek")&"_Break1Start ")
rs1.Fields.Item("Break1Duration") = Request(rs1.Fields.Item("DayofWeek")&"_Break1Durat ion")
rs1.Fields.Item("LunchStart") = Request(rs1.Fields.Item("DayofWeek")&"_LunchStart" )
rs1.Fields.Item("LunchDuration") = Request(rs1.Fields.Item("DayofWeek")&"_LunchDurati on")
rs1.Fields.Item("Break2Start") = Request(rs1.Fields.Item("DayofWeek")&"_Break2Start ")
rs1.Fields.Item("Break2Duration") = Request(rs1.Fields.Item("DayofWeek")&"_Break2Durat ion")
rs1.Fields.Item("ShiftEnd") = Request(rs1.Fields.Item("DayofWeek")&"_ShiftEnd")
rs1.Update
rs1.MoveNext
Loop
conn1.CommitTrans 'commit transactions made
rs1.Close
conn1.Close
set rs1 = nothing
set conn1 = nothing
---------------------------------------------------------------------
the SQL query has nothing special about it, so i did not write it here.
As you can see i am trying to update the table record by record within each record several field values are going to chance.
My question is why this method is not working, and what should i do about the rs1.Open extra parameters, have i used the correct ones?
Here are the erros that i get when i click the submit changes button in the previous page
---------------------------------------------------------------------
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
/MyWeb/rsschange.asp, line 77
When i used 3,3 as the rs1.Open parameters
---------------------------------------------------------------------
And Sometimes:
When i use 3,4 as the rs1.Open parameters the page runs ok but not updates really occurr to the database, its like they are just cached for my own viewing and that's it.
---------------------------------------------------------------------
Also:
When i use 0,2 as the rs1.Open parameters just like in the code mentioned above I get the following error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/MyWeb/rsschange.asp, line 77
---------------------------------------------------------------------
I would appreciate any comments or help on this topic or even a general help tip about how to update a record(s) in a database based on the input of a user form.
Thanks alot
Peace/
|
|

September 15th, 2004, 08:00 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
|
|
hello,
or you use objConn.execute strQry
'strQry is SQL statement(update in this case)
objConn.beginTrans
do until rs.eof
strQry="update ...."
objConn.execute strQry
if Err.number <> 0 then checkError
rs.movenext
loop
objConn.commitTrans
sub checkError()
response.write Err.description
objConn.rollbackTrans
'.....
end sub
Rajani
|
|

September 15th, 2004, 09:04 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Actually, After i have wrote my huge topic, i went to do the last thing i totally forgot to do, which is check the permissions on the IIS configuration screen for my default web site. I have checked the write permission box, then tried running the site again, and it really worked. This is only true when i made a copy of the database and put it in the same C:\Inetpup\wwwroot\MyWeb\ folder which is where all the site's .ASP and .HTM files reside. Is there anyway i can have that database stored in it's original location (C:\) while being able to write to it, because if otherwise, if i dont do it the way i mentioned above, it wont update, but it wont give me errors either!!
|
|

September 15th, 2004, 10:43 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Give the IIS user (IUSR_ComputerName) the read/write permission on the folder where to the mdb resides. That should solve the problem.
On the windows explorer, right click on the folder that contains .mdb file and select properties, go to security tab, add ISUR_Computername user to the list and give the needed permission to that user.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

September 16th, 2004, 07:47 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks alot, buddy. It worked. I hope that this topic will help other people who might face the same problem.
Thanks
|
|

September 16th, 2004, 11:10 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You are welcome!
You could have searched for that error here in the asp forums. This was discussed a lot of times here.;)
_________________________
- Vijay G
Strive for Perfection
|
|
 |