1. Igor Perisic
  2. .NET DataStore
  3. Wednesday, 26 October 2022 17:41 PM UTC

I'm looking into making updates to a database. So far I have normal updates working "datastore.Update();" However I'm curious if there is a way to do Bulk Updates with the C# datastores? 

Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Thursday, 27 October 2022 14:53 PM UTC
  2. .NET DataStore
  3. # 1

Hi Igor,

Please try to change the DataContext.ContextOptions.BatchExecuting property to 'true' before calling the DataStore.Update method, refer to:

https://docs.appeon.com/snapobjects/4.x/api_reference/SnapObjects.Data/IDataContextOptions/Property/BatchExecuting.html

I'm not sure if this answer is what you asked. If still need help, please provide more details about this question.

Regards, Logan

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 26 October 2022 18:06 PM UTC
  2. .NET DataStore
  3. # 2

One way to simulate this would be to have a Global or Instance variable (whichever is more appropriate) of a datawindow array: 
       datawindow     idw_array[]

Whenever a DW is created dyamically you add a pointer to that array:
       datawindow     ldw1
       ldw1 = CREATE datawindow
       ll_max = UpperBound (idw_array)
       idw_array [ll_max + 1] = ldw1                         // Clean up the array if ldw goes out of scope

Whenever a DW is created in the IDE you arr a pointer when the object is opened:
      // Open event of window
      ll_max = UpperBound (idw_array)
      ll_max = ll_max + 1

       idw_array [ll_max] = dw_first

      ll_max = ll_max + 1
       idw_array [ll_max] = dw_second
      .
      .
      .
     

When you are ready for the Update, scroll through the array
      ll_max = UpperBound (idw_array)
      FOR ll_idx = 1 TO ll_max

           ldw = idw_array [ll_idx]
           ll_rc = ldw.Update ()            // If parameters are required use a  CASE statement here
           IF (ll_rc <> 1) THEN
              // error handling here
           END IF

      NEXT

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.