PC Review


Reply
Thread Tools Rate Thread

ADO Recordset Opens as Read Only

 
 
Wayne Wengert
Guest
Posts: n/a
 
      27th Jul 2003
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") = "$$$$"


--
------------------------------------
Wayne Wengert
(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      28th Jul 2003
On Sat, 26 Jul 2003 21:01:25 -0600, "Wayne Wengert" <(E-Mail Removed)> wrote:

¤ 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 Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Wayne Wengert
Guest
Posts: n/a
 
      28th Jul 2003
Sorry - the connection "myConn" is established in the code that created the
database - that seems to work fine.

Wayne

"Paul Clement" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Sat, 26 Jul 2003 21:01:25 -0600, "Wayne Wengert" <(E-Mail Removed)>

wrote:
>
> ¤ 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 Removed)
> Microsoft MVP (Visual Basic)



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset not updateable message displayed when form opens Larry Kahm Microsoft Access 1 11th Jun 2009 09:14 PM
A document that isn't read only, randomly opens as read only? =?Utf-8?B?QmFyYmFyYQ==?= Microsoft Word Document Management 0 15th Nov 2005 01:15 PM
ADO recordset closed, cannot read Michael Kellogg Microsoft Excel Programming 2 6th May 2005 10:22 PM
DB opens as read-only when another user opens it =?Utf-8?B?U3VzYW4gTA==?= Microsoft Access Security 2 29th Apr 2005 06:42 PM
Database Opens, This Recordset Not Updatable Dave Elliott Microsoft Access Forms 1 2nd Jun 2004 09:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:37 AM.