awolarczuk
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.adOpe nDynamic, ADODB.LockTypeEnum.adLockP essimistic )
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.OL EDB.4.0;Da ta 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
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.adOpe
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.OL
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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