Solved

Update as/400 recordset using vb script

Posted on 2003-12-11
7
763 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let’s face it: one of the reasons your organization chose a SaaS solution (whether Microsoft Dynamics 365, Netsuite or SAP) is that it is subscription-based. The upkeep is done. Or so you think.
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 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