I got a collection read only error, 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 are my functions.
<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
Function openDB() As Object
objConn = New ADODB.Connection
objConn.Open(dbDNS) '("dbfile")
objRS = New ADODB.Recordset
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
Someone suggest me to use a forward-only cursor and the update
statement to solve this problem. But I don't know how to do it. Anyone
give me an example? Many Thanks
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*