?
Solved

property item is readonly problem

Posted on 2007-10-10
2
Medium Priority
?
2,583 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
0
Comment
Question by:awolarczuk
2 Comments
 
LVL 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 total points
ID: 20054332
Hi

You'll probably need to specify the correct property....

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

Also, since the advent of .Net, ADODB has been replaced by ADO.NET. See here for an overview of ADO.NET -> http://msdn2.microsoft.com/en-us/library/h43ks021(VS.71).aspx

Regards,

Wayne
0
 
LVL 27

Expert Comment

by:planocz
ID: 20059174
HI awolarczuk,

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

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22445836.html
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question