Link to home
Start Free TrialLog in
Avatar of awolarczuk
awolarczukFlag for Australia

asked on

property item is readonly problem

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
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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/questions/22445836/Need-help-converting-VB6-DAO-code-to-VB-NET-2003-ADO-code.html