.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DAO rs Property is Read Only

1 REPLY 1
Reply
Message 1 of 2
Anonymous
528 Views, 1 Reply

DAO rs Property is Read Only

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
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost