468,514 Members | 1,690 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,514 developers. It's quick & easy.

Current Recordset does not support updating

7
Hi Anyone help?

Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
/anata/Send_OrderList.asp, line 102

My Code as below
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.  
  3. CC_OrderAction=Request.ServerVariables("SCRIPT_NAME")
  4. if Request("CC_OrderInsert") <> "" then
  5. TimeKey=GetTimeInMillisec()
  6. rsTimekey.AddNew                                 (This is line102)
  7. rsTimekey("Timekey")=TimeKey
  8. For Each fld in rsTimekey.Fields
  9. if Len(Request(fld.Name)) > 0 then
  10. fld.Value = Request(fld.Name)
  11. end if
  12. Next
  13. rsTimekey.Update
  14. rsTimekey.Requery
  15. rsTimekey.Filter= "Timekey='" & TimeKey & "'"
  16. Session("OrderID")=Session("OrderID")
  17. end if
Feb 26 '10 #1
9 6102
GazMathias
200 Expert 100+
You need to use a locktype that supports updating in the ADO recordset.open method, the default is read only.

Example
Expand|Select|Wrap|Line Numbers
  1. rs.open SQL,conn,1,2
  2.  
Hope that helps.

Gaz
Feb 26 '10 #2
AAKK
7
Hi Thank for your reply
sorry I m new for this asp
May i know where to put this code?

I try to rewrite the code to below
'
CC_OrderAction=Request.ServerVariables("SCRIPT_NAM E")
if Request("CC_OrderInsert") <> "" then
TimeKey=GetTimeInMillisec()
rsTimekey.open SQL,conn,1,2
rsTimekey.AddNew

rsTimekey("Timekey")=TimeKey
For Each fld in rsTimekey.Fields
if Len(Request(fld.Name)) > 0 then
fld.Value = Request(fld.Name)
end if
Next
rsTimekey.Update
rsTimekey.Requery
rsTimekey.Filter= "Timekey='" & TimeKey & "'"
Session("OrderID")=rsTimekey("OrderID")
end if
%>

but it turn up again message

Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.
/anata/Send_OrderList.asp, line 105
Feb 27 '10 #3
GazMathias
200 Expert 100+
Hi

Somewhere in your code you should have a line that starts like this:
Expand|Select|Wrap|Line Numbers
  1. rsTimekey.Open '... more code
  2.  
Try adding this before it:
Expand|Select|Wrap|Line Numbers
  1. rsTimekey.LockType = adLockPessimistic
  2.  
Hope that helps

Gaz.
Feb 27 '10 #4
AAKK
7
HI
after studying the locktype
i still could not figure out the place to insert
therefore,better to provide you all code
easy for you check
hoping you will help
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%>
  2. <!--#include file="inc_CharonCart.asp" -->
  3. <script language="javascript" runat="server">
  4.  
  5. function GetTimeInMillisec()
  6. {
  7.     var Now = new Date()
  8.     var TimeStamp = Now.getTime()
  9.  
  10.     return TimeStamp
  11. }
  12.  
  13. </script>
  14. <!--#include file="Connections/Data.asp" -->
  15. <!--#include virtual="/anata/Connections/data.asp" -->
  16. <%
  17. Dim rs1stCatalogs
  18. Dim rs1stCatalogs_cmd
  19. Dim rs1stCatalogs_numRows
  20.  
  21. Set rs1stCatalogs_cmd = Server.CreateObject ("ADODB.Command")
  22. rs1stCatalogs_cmd.ActiveConnection = MM_Data_STRING
  23. rs1stCatalogs_cmd.CommandText = "SELECT * FROM tCatalogs ORDER BY CatalogID ASC" 
  24. rs1stCatalogs_cmd.Prepared = true
  25.  
  26. Set rs1stCatalogs = rs1stCatalogs_cmd.Execute
  27. rs1stCatalogs_numRows = 0
  28. %>
  29. <%
  30. Dim rsShowCatalog
  31. Dim rsShowCatalog_cmd
  32. Dim rsShowCatalog_numRows
  33.  
  34. Set rsShowCatalog_cmd = Server.CreateObject ("ADODB.Command")
  35. rsShowCatalog_cmd.ActiveConnection = MM_Data_STRING
  36. rsShowCatalog_cmd.CommandText = "SELECT * FROM tCatalogs" 
  37. rsShowCatalog_cmd.Prepared = true
  38.  
  39. Set rsShowCatalog = rsShowCatalog_cmd.Execute
  40. rsShowCatalog_numRows = 0
  41. %>
  42. <%
  43. Dim rsPayData__MMColParam
  44. rsPayData__MMColParam = "1"
  45. If (Session("OrderID") <> "") Then 
  46.   rsPayData__MMColParam = Session("OrderID")
  47. End If
  48. %>
  49. <%
  50. Dim rsPayData
  51. Dim rsPayData_cmd
  52. Dim rsPayData_numRows
  53.  
  54. Set rsPayData_cmd = Server.CreateObject ("ADODB.Command")
  55. rsPayData_cmd.ActiveConnection = MM_data_STRING
  56. rsPayData_cmd.CommandText = "SELECT PayWay, GrandPrice FROM tOrderData WHERE OrderID = ?" 
  57. rsPayData_cmd.Prepared = true
  58. rsPayData_cmd.Parameters.Append rsPayData_cmd.CreateParameter("param1", 5, 1, -1, rsPayData__MMColParam) ' adDouble
  59.  
  60. Set rsPayData = rsPayData_cmd.Execute
  61. rsPayData_numRows = 0
  62. %>
  63.  
  64. <%
  65. Dim rsOrderList
  66. Dim rsOrderList_cmd
  67. Dim rsOrderList_numRows
  68.  
  69. Set rsOrderList_cmd = Server.CreateObject ("ADODB.Command")
  70. rsOrderList_cmd.ActiveConnection = MM_data_STRING
  71. rsOrderList_cmd.CommandText = "SELECT * FROM tOrderList" 
  72. rsOrderList_cmd.Prepared = true
  73.  
  74. Set rsOrderList = rsOrderList_cmd.Execute
  75. rsOrderList_numRows = 0
  76. %>
  77. <%
  78.  
  79. Dim rsTimekey
  80. Dim rsTimekey_cmd
  81. Dim rsTimekey_numRows
  82.  
  83. Set rsTimekey_cmd = Server.CreateObject ("ADODB.Command")
  84. rsTimekey_cmd.ActiveConnection = MM_data_STRING
  85. rsTimekey_cmd.CommandText = "SELECT * FROM tOrderTimekey" 
  86.  
  87. Set rsTimekey = rsTimekey_cmd.Execute
  88. rsTimekey_numRows = 0
  89. %>
  90. <%
  91. Dim Repeat1__numRows
  92. Dim Repeat1__index
  93.  
  94. Repeat1__numRows = -1
  95. Repeat1__index = 0
  96. rs1stCatalogs_numRows = rs1stCatalogs_numRows + Repeat1__numRows
  97. %>
  98. <% 
  99. '
  100. 'Insert record into Orders recordset when form is submitted
  101. 'and store the unique OrderID
  102. '
  103. CC_OrderAction=Request.ServerVariables("SCRIPT_NAME")
  104. if Request("CC_OrderInsert") <> "" then
  105. TimeKey=GetTimeInMillisec()
  106.  
  107. rsTimekey("Timekey")=TimeKey
  108. For Each fld in rsTimekey.Fields
  109. if Len(Request(fld.Name)) > 0 then
  110. fld.Value = Request(fld.Name)
  111. end if
  112. Next
  113. rsTimekey.Update
  114. rsTimekey.Requery
  115. rsTimekey.Filter= "Timekey='" & TimeKey & "'"
  116. Session("OrderID")=rsTimekey("OrderID")
  117. end if
  118. %>
  119. <% 
  120.  
  121. CC_OrderAction=Request.ServerVariables("SCRIPT_NAME")
  122. if Request("CC_OrderInsert") <> "" then
  123. TimeKey=GetTimeInMillisec()
  124. rsTimekey.AddNew
  125. rsTimekey("Timekey")=TimeKey
  126. For Each fld in rsTimekey.Fields
  127. if Len(Request(fld.Name)) > 0 then
  128. fld.Value = Request(fld.Name)
  129. end if
  130. Next
  131. rsTimekey.Update
  132. rsTimekey.Requery
  133. rsTimekey.Filter= "Timekey='" & TimeKey & "'"
  134. Session("OrderID")=Session("OrderID")
  135. end if
  136. %>
Mar 1 '10 #5
jhardman
3,405 Expert 2GB
the more common way to open a recordset is this:
Expand|Select|Wrap|Line Numbers
  1. dim rs, conn
  2. set conn=server.createObject("adodb.connection")
  3. conn.open connectionString
  4.  
  5. set rs = server.createObject("adodb.recordset")
  6. rs.open command, conn, locktype, cursortype 
Your method doesn't use this syntax, you declare the recordset by making a adodb.command, and then calling execute and dumping the result into the recordset variable. I don't think that method will work if you want to update your recordset. I suggest you rework the code to use the method I highlighted above, locktype and cursortype are both constants, 2 and 3 will work for you. Let me know if this helps.

Jared

BTW, I'm going to add code tags to make your post more readable. In the future please enclose your code in [ code]...[/code] tags
Mar 1 '10 #6
AAKK
7
HI Thank
it work
thank for your helping
Mar 3 '10 #7
AAKK
7
Microsoft OLE DB Provider for ODBC Drivers (0x80040E2F)
[Microsoft][ODBC Microsoft Access Driver] The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
/anata/Send_OrderList.asp, line 205

Expand|Select|Wrap|Line Numbers
  1. ODRecordset.AddNew
  2. ODRecordset.Fields(UniqueIdColumn)=UniqueIdValue
  3. ODRecordset.Fields("Quantity")=CCcart(CC_Quantity,i)
  4. ODRecordset.Fields("Name")=CCcart(CC_Name,i)
  5. ODRecordset.Fields("SalePrice")=CCcart(CC_Price,i)
  6. rsOrderList.Update'(line 205)
Mar 3 '10 #8
jhardman
3,405 Expert 2GB
I assume the UniqueIdColumn is an auto-incrementing key field. Don't set the auto-increment number! The recordset object will do that automatically when you call "update".

Jared

Please type the following after your code block:
[/code]
And type this right before your code block:
[code]
failure to do so could make me lose my temper
Mar 3 '10 #9
AAKK
7
Hi My data is Access
so Now,I took away the prime key
it look like work
THK
Mar 6 '10 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by barret bonden | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.