/ Forums / Advansys Formativ / Creating Solutions with Formativ / Data Retrieval/Update Form based processing / Reply To: Data Retrieval/Update Form based processing

#7768
Support 3
Participant

    Sorry, we don’t have any examples relating to your questions. Based on your previous post, you may need to open the connection once and all other function/sub should use the opened database connection. Make sure to close the connection at the end of the process. Here is an example of the structure you can use:

      
    Sub Main(Client, GWEvent)
    
      dim oADOObj
    
      set oADOObj = nothing
    
      if not OpenDataBase() then
        exit sub
      end if
    
      select case iDlg.execute
        case Btn1 AddNewRecord(oADOObj)
        case Btn3 DisplayAllRecords(oADOObj)
        case Btn4 FindRecord(oADOObj)
        case Btn5 EditRecord(oADOObj)
      end select
    
      CloseDataBase(oADOObj)
    
      set oADOObj = nothing
    
    End Sub
    
    
    ' Open Database connection
    function OpenDataBase(byref aADOObj)
    
     OpenDataBase = false
     Set aADOObj = CreateObject("ADODB.Connection")
    
     ' << Setup your connection string and other process relate to opening database >>
    
    end function
    
    
    
    ' Close Database connection
    function CloseDataBase(byref aADOObj)
    
      if aADOObj is nothing then
        exit function
      end if
    
      aADOObj.close
    
    end function
    
    
    ' Add record as the connection is already opened so no need to open in here
    Sub AddNewRecord(byref aADOObj)
    
      if aADOObj is nothing then
        exit sub
      end if
    
    end sub
    

    Regards,
    Advansys Support

    [This message was edited by Support 3 on October 26, 2006 at 10:31 PM.]

    [This message was edited by Support 2 on October 27, 2006 at 12:54 AM.]