ADO Recordset Opens as Read Only

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I am trying to rewrite a VB6 App in VB.NET but, from what I understand, I
must use ADO/ADOX to create a database. I tried to copy over my o;ld VB6
code that creates the DB, Creates a table and then adds the 1st record (a
contol record). The code that attempts to set the values for that 1st record
has errors claiming it is Read Only? (see relevant code below)

Questions:

1. Why is that recordset ReadOnly?

2. Can I create the table in VB.NET - if so - How?


================== code ====================
myRS = New ADODB.Recordset()

myRS.CursorType = adOpenKeyset

myRS.Open("[" & TableName & "]", myConn, adOpenDynamic, adLockOptimistic)

'*** Create control record ***

With myRS

..AddNew()

..Fields("Unit") = "$$$$"
 
¤ I am trying to rewrite a VB6 App in VB.NET but, from what I understand, I
¤ must use ADO/ADOX to create a database. I tried to copy over my o;ld VB6
¤ code that creates the DB, Creates a table and then adds the 1st record (a
¤ contol record). The code that attempts to set the values for that 1st record
¤ has errors claiming it is Read Only? (see relevant code below)
¤
¤ Questions:
¤
¤ 1. Why is that recordset ReadOnly?
¤
¤ 2. Can I create the table in VB.NET - if so - How?
¤
¤
¤ ================== code ====================
¤ myRS = New ADODB.Recordset()
¤
¤ myRS.CursorType = adOpenKeyset
¤
¤ myRS.Open("[" & TableName & "]", myConn, adOpenDynamic, adLockOptimistic)
¤
¤ '*** Create control record ***
¤
¤ With myRS
¤
¤ .AddNew()
¤
¤ .Fields("Unit") = "$$$$"

I don't see where you establish your database connection. Is there some code missing here?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Sorry - the connection "myConn" is established in the code that created the
database - that seems to work fine.

Wayne

Paul Clement said:
¤ I am trying to rewrite a VB6 App in VB.NET but, from what I understand, I
¤ must use ADO/ADOX to create a database. I tried to copy over my o;ld VB6
¤ code that creates the DB, Creates a table and then adds the 1st record (a
¤ contol record). The code that attempts to set the values for that 1st record
¤ has errors claiming it is Read Only? (see relevant code below)
¤
¤ Questions:
¤
¤ 1. Why is that recordset ReadOnly?
¤
¤ 2. Can I create the table in VB.NET - if so - How?
¤
¤
¤ ================== code ====================
¤ myRS = New ADODB.Recordset()
¤
¤ myRS.CursorType = adOpenKeyset
¤
¤ myRS.Open("[" & TableName & "]", myConn, adOpenDynamic, adLockOptimistic)
¤
¤ '*** Create control record ***
¤
¤ With myRS
¤
¤ .AddNew()
¤
¤ .Fields("Unit") = "$$$$"

I don't see where you establish your database connection. Is there some code missing here?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top