×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ADO record sets. Does anybody know whats wrong with this code?

ADO record sets. Does anybody know whats wrong with this code?

ADO record sets. Does anybody know whats wrong with this code?

(OP)
When i execute the following code I get
'
Error 3251: The operation requested by the application is not supported by the provide.
'
When AddNew is executed.

Am i using the correct methods for ADO programming as i'm new to the concept? I get something similar using the Data Environment.

Thanks Nigel

Dim adocmdOrderHeader As adodb.Command
Dim WithEvents adorsOrderHeader As adodb.Recordset
Dim db As adodb.Connection, strSQL As String
Set db = New Connection
Set adocmdOrderHeader = New Command
Set adorsOrderHeader = New Recordset
Set adorsOrderDetails = New Recordset
db.CursorLocation = adUseClient

db.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=\\Abc\sys1\USERS\NDR\source\Purchase Order\PurchaseOrder.mdb;"

db.Open

strSQL = "SELECT PONumber,OrderDate,Department,SupplierName,SuppliersAddress,DeliveryAddress,DeliveryInstructions,OrderTotal " _
& "FROM tblHeader " _
& "ORDER BY PONumber;"

adocmdOrderHeader.ActiveConnection = db
adocmdOrderHeader.CommandType = adCmdText
adocmdOrderHeader.CommandText = strSQL
Set adorsOrderHeader = adocmdOrderHeader.Execute
With adorsOrderHeader
.AddNew
!SupplierName = "Nigel Was here"
.UpdateBatch adAffectAll
End With

RE: ADO record sets. Does anybody know whats wrong with this code?

You haven't specified a lock type for your record set. It's being opened as read only, and you are trying to add a row.

Try this code instead of the command object and the record set.

Set adorsOrderHeader = New ADODB.Recordset
With adorsOrderHeader
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Open strSql, db, , , adCmdText
End With

RE: ADO record sets. Does anybody know whats wrong with this code?

(OP)
thanks for that, it does work as you have specified.
However it does not really solve my problem, as I'm triying to use the Data Environment, and the code I used emulated something simular the DE would do (I think). I cannot get my code or the DE to allow any form of updating.

Nigel

RE: ADO record sets. Does anybody know whats wrong with this code?

It works fine with the DE as well. Commands in the DE automatically have a recordset associated with them preceeded with "rs". Lets say you have a command called MyCommand. And you have a data environment called DE.

Dim Rs as Adodb.Recordset

With DE
.rsMyCommand.CursorLocation = adUseClient
.rsMyCommand.CursorType = adOpenKeyset
.rsMyCommand.LockType = adLockPessimistic
.MyCommand 'Opens the recordset
set Rs = .rsMyCommand

End With


Rs or rsCommand is now updatable. If you had used a lock type of batch optimistic, then you could use disconnected recordsets as well as updatebatch.

RE: ADO record sets. Does anybody know whats wrong with this code?

(OP)
Thanks I think I now no where I was going wrong.

Nigel

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close