articles:

collection is read only exception

This little gem cropped up the other day while putting together a quick aspx page to pull out some records from an access database. Essentially a category ID was passed in the querystring and this was then used as select parameter for an access datasource.

Pretty normal stuff, after all querystring is one of the options when you configure an access data source in design view. However, when creating the access data source programmatically and assigning the querystring as one of the select parameters a "Collection is read only" exception was thrown when the page was run.

On this occasion rather than seek the truth so to speak, a work around was arrived at:

From this:

Dim a As New AccessDataSource
a.DataFile = Server.MapPath("somedb.mdb")
a.SelectParameters.Add("Id",TypeCode.Int32,request.querystring("ID"))
....

To this:

Dim tmp As String = request.querystring("ID")
Dim a As New AccessDataSource
a.DataFile = Server.MapPath("somedb.mdb")
a.SelectParameters.Add("Id",TypeCode.Int32,tmp)
....

Changed that and bingo

Post a comment

name:
(optional)

email:
(optional)

comment: