.NET

Reply
*Nate Hunter
Message 1 of 2 (297 Views)

DAO rs Property is Read Only

297 Views, 1 Replies
03-03-2006 11:12 AM
I am currently upgrading my code from VB6 to VB.NET. I ran into a problem I
can not solve so I am asking the experts. The line:
rs("Elec") = "Test" displays as an error. The error reads: Property "Item"
is ReadOnly

Any ideas what I am doing wrong or another suggestion how I can edit my db?
Imports DAO

Dim db As Database, rs As DAO.Recordset
db = dbEng.OpenDatabase(wbPath & "VBIn.mdb") ' Database Name
rs = db.OpenRecordset("VPIn") 'table name
rs.MoveFirst()
For k = 0 To rs.RecordCount - 1
If rs("ArchVP") = wbTab Then
Select Case VB.Left(Disc, 1)
Case "E"
rs.Edit()
rs("Elec") = "Test" ' Property "Item" is ReadOnly
rs.Update()
GoTo WroteData
Case "H"
Case "P"
Case "S"
End Select
End If
rs.MoveNext()
Next k
WroteData:
rs.Close()
rs = Nothing
db.Close()
db = Nothing
*Norman Yuan
Message 2 of 2 (297 Views)

Re: DAO rs Property is Read Only

03-03-2006 12:40 PM in reply to: *Nate Hunter
Have not worked with DAO for many years. Here is possible cause of your
problem:

Database.OpenRecordSet() takes 4 parameters with last three being optional.
I guess, if you do not specify the extra option parameters, the RecordSet
return is Forword-Only and Readd-Only. If you want to write values to the
RecordSet and update back to data store, you need to open a recordSet with
appropriate options specified.

As additional comment, I do not see the point to convert your code from VB
to .NET if you stick with old COM technology (DAO, and even VB.Left()...).

"Nate Hunter" wrote in message
news:5101533@discussion.autodesk.com...
I am currently upgrading my code from VB6 to VB.NET. I ran into a problem I
can not solve so I am asking the experts. The line:
rs("Elec") = "Test" displays as an error. The error reads: Property "Item"
is ReadOnly

Any ideas what I am doing wrong or another suggestion how I can edit my db?
Imports DAO

Dim db As Database, rs As DAO.Recordset
db = dbEng.OpenDatabase(wbPath & "VBIn.mdb") ' Database Name
rs = db.OpenRecordset("VPIn") 'table name
rs.MoveFirst()
For k = 0 To rs.RecordCount - 1
If rs("ArchVP") = wbTab Then
Select Case VB.Left(Disc, 1)
Case "E"
rs.Edit()
rs("Elec") = "Test" ' Property "Item" is ReadOnly
rs.Update()
GoTo WroteData
Case "H"
Case "P"
Case "S"
End Select
End If
rs.MoveNext()
Next k
WroteData:
rs.Close()
rs = Nothing
db.Close()
db = Nothing
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.