Collection Read Only ERROR, help

From: ronaldlee (leeronald1982_at_yahoo-dot-com.no-spam.invalid)
Date: 12/18/04


Date: 17 Dec 2004 18:59:04 -0600

Hi, I am using ADO code and
I got a collection read only error. I have setted the LockType to
Optimistic and CursorType to Dynamic, but it still have the same
error, anyone have any ideas? I am appreciate for your help.

Ron

Below is the error message.

Collection is read-only.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Collection is
read-only.

Source Error:

Line 14: objRS.Open("INSERT INTO Customers (Customer_UserName,
Customer_Password, Customer_Name, Customer_Email,
Customer_Address_Line1, Customer_Address_Line2,
Customer_Address_PostCode, Customer_Address_County,
Customer_Telephone, Customer_Fax) VALUES ('" &
SQL_safe(Request.Form.Item("username")) & "','" &
SQL_safe(Request.Form.Item("user_password")) & "','" &
SQL_safe(Request.Form.Item("realname")) & "', '" &
SQL_safe(Request.Form.Item("email")) & "', '" &
SQL_safe(Request.Form.Item("billing_house")) & "', '" &
SQL_safe(Request.Form.Item("billing_street")) & "', '" &
SQL_safe(Request.Form.Item("billing_area")) & "', '" &
SQL_safe(Request.Form.Item("billing_town")) & "', '" &
SQL_safe(Request.Form.Item("billing_county")) & "', '" &
SQL_safe(Request.Form.Item("billing_postcode")) & "', '" &
SQL_safe(Request.Form.Item("telephone")) & "', '" &
SQL_safe(Request.Form.Item("fax")) & "')", objConn)

below is my function

<script language="VB" runat="Server">
Dim objConn As ADODB.Connection
    Dim objRS As ADODB.Recordset
    Dim dbDNS As String
Dim name As Object
    Dim value As Object
    'Set ADODB.LockTypeEnum.adLockOptimistic
    'Set ADODB.CursorTypeEnum.adOpenDynamic
    Const adOpenDynamic = 2
    Const adLockOptimistic = 3

    
    
    Function openDB() As Object
        Const adOpenDynamic = 2
        Const adLockOptimistic = 3
      
       
       
        objConn = New ADODB.Connection
        objConn.Open("COMP224_Assignment_Database")
        

        objRS = New ADODB.Recordset
        objRS.LockType = ADODB.LockTypeEnum.adLockOptimistic
        objRS.CursorType = ADODB.CursorTypeEnum.adOpenDynamic
    
       
    End Function

Function closeDB() As Object
        ' If the RecordSet has a state of 1 (open) close it
        If objRS.state = 1 Then
                objRS.Close()
        End If
        
        objConn.Close()
        objConn = Nothing
End Function

*-----------------------*
        Posted at:
  www.GroupSrv.com
*-----------------------*



Relevant Pages