Solved

Update as/400 recordset using vb script

Posted on 2003-12-11
7
757 Views
Last Modified: 2012-06-27
I am having a problem getting my recordset to be updateable.  I keep getting an error message say this recordset does not support update, etc.  I have tried using all combinations of the lock cursor type to no prevail. here is a snippet of my code.

set vConn = server.createobject("ADODB.Connection")
 vConn.Open "DSN=mydsn;UID=meuser;PWD=mepwd"
partnumber = "62222"
set vRS = server.createobject("ADODB.Recordset")
set vRS.ActivEConnection = vConn
sql1 = "SELECT * FROM FLELIB.VTPRTM Where PMPRT = '" & partnumber & "'"
    With vRS
         .CursorType = adOpenDynamic
         .locktype = adLockoptimistic
         .CursorLocation = adUseClient
         .CacheSize = 20
         .MaxRecords = 1
           'Open the result
         .Open strSQL, vConn

         'Verify the cursor type used.
         Debug.Print .CursorLocation
         Debug.Print .CursorType
     end with
   
0
Comment
Question by:digdug89
7 Comments
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 9923998
Have you checked the security on the AS/400 for thet file?
0
 
LVL 14

Expert Comment

by:daveslater
ID: 9926794
Hi
the easiest way is is not to update the record set but to issue an update statement

Set cmd = CreateObject("ADODB.command")
Set cmd.ActiveConnection = vconn
cmd.commandtext = "Update lib.file set field='Update from Pc' where KEY_DB='Value' "
cmd.Execute

Regards

Dave
0
 
LVL 14

Accepted Solution

by:
daveslater earned 350 total points
ID: 9928562
Hi
just thinking a bit more about how you are tyring to go about this
In RPG if we are using SQL to update we do the following
Declare a cursor
open the cursor for update of felds
UPDATE FILE SET DAVE = 'A' WHERE CURRENT OF CSR    

As you are using ADO this is an SQL interface therefore the above method is the only way you can ahcieve it.

The only other way is to use a static ODBC and open a reccord set using DAO and qualified library / file name

Dave
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:digdug89
ID: 9949527
actually i got the code to work with the following code.  I am showing this to show you. Thanks so much for your response.

sql1 = "SELECT * FROM FLELIB.VTPRTM Where PMPRT = '" & partno & "'"
    With vRS
         .CursorType = 3
         .locktype = 3
         .CacheSize = 20
         .MaxRecords = 2
           'Open the result
         .Open sql1, vConn
       
     End With
0
 

Author Comment

by:digdug89
ID: 9949557
Just fyi, this code will allow you you to update the current recordset...
0
 
LVL 14

Expert Comment

by:daveslater
ID: 9949571
Hi
I like it when we get feed back.

Cheers


Dave
0
 

Expert Comment

by:beauzero
ID: 10402938
Go with Dave's suggestion on using the strict "Update" statement and if you can using a stored proc. on the 400 side will greatly (by about a factor of 20) increase the speed.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now