docs.intersystems.com
MultiValue Quick Start Tutorial
CacheDataReader: Update
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

The following code executes an SQL UPDATE on a row of the MVFILE.PERSON table. In more detail, the code does the following:

  1. Creates a connection to Caché using the CMP CacheConnection class.
  2. Opens the database connection.
  3. Creates and executes the UPDATE using the CMP CacheCommand and CacheDataReader classes.
  4. Displays the number of affected rows.
  5. Closes the connection.
 //Create the connection
 string cacheString =
 "Server=localhost;Port=1972; Log File=c:\\MVTutorial.log;Namespace=MYACCOUNT;" 
 + "Password=SYS;User ID=_system;";
  cnCache = new CacheConnection(cacheString);

  //Open the connection
  cnCache.Open();

  //Create and execute the update
  String sql = "UPDATE MVFILE.PERSON (AGE,PHONE) VALUES" +
  " ('41','111-111-1111,222-222-2222') WHERE NAME='IDLE,JIM'";
  CacheCommand command = new CacheCommand(sql, cnCache);
  int rows = command.ExecuteNonQuery();
           
  //Display the number of affected rows
  Console.WriteLine("rows {0}", rows);
            
  //Close the connection
  cnCache.Close();         
 
Note:
The above code is contained in RelationalAccess.cs. The file is in <cachesys>\Dev\tutorials\mv. Executing the .NET Examples contains step-by-step instructions for executing this code.


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA