.NET

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

DAO rs Property is Read Only

301 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 (301 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.