We help IT Professionals succeed at work.

property item is readonly problem

2,887 Views
Last Modified: 2013-11-26
Hey guy i have only just started using Vb.net and having a issue with connecting to a access mdb database

it looks like it connects ok but i am getting a "property item is readonly vb.net" when u try to access any of the records

 connect()
        Dim rs As New ADODB.Recordset
        Dim sql As String
        Dim count As Integer

        sql = "select * from [pointers]"
        Debug.Print(sql)
        rs.Open(sql, cnn1, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic)

        rs.Fields("stockid") = stockn.Text + 1


and this is the connection i am using

Option Explicit On
Module Module1

    Public DBFile As String
    Public Source As String
    Public cnn1 As New ADODB.Connection
    Public ShowExt As Boolean
    Private HasAccess As Boolean



    Public Sub connect()

        Dim rs As New ADODB.Recordset
        Dim sql As String


        DBFile = Application.ExecutablePath()
        If Right(DBFile, 1) <> "\" Then
            DBFile = DBFile & "\"
        End If
        DBFile = "posit.mdb"
        cnn1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & DBFile & ";jet oledb"

        cnn1.Open()

DBSafe:
        Exit Sub
DBError:
        MsgBox(Err.Description & vbCrLf & vbCrLf & "Failed to 'connect to database", vbCritical, "Error")
        Resume DBSafe
    End Sub
End Module
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
HI awolarczuk,

Here is a sample that has helped others.
I would not use recordsets, move to datasets (almost the samething)

https://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22445836.html
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.