EndTransaction
Previous Top Next

Each time you execute a command on the database a transaction is created automatically if it wasn't opened earlier.
When you are executing several commands one after another it is much faster to start with BeginTransaction and finish with EndTransaction.
That way, only one transaction will be created for the entire block.
Syntax: EndTransaction

Example:
      Con.BeginTransaction 'Starts a block of I/O with the database.
      cmd.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table'" 'Finds all the tables in this database
      Reader.Value = cmd.ExecuteReader
      Do while reader.ReadNextRow = True
            Tree.AddNewNode(reader.GetValue(0))
      loop
      Reader.Close
      for i = 0 to Tree.Count - 1
            Node.Value = Tree.GetNode(i)
            cmd.CommandText = "PRAGMA table_info ('" & Node.Text & "')" 'Special SQLite command to find the table's metadata.
            reader.Value = cmd.ExecuteReader
            Do while Reader.ReadNextRow = True
                  Node.AddNewNode(Reader.GetValue(1) & " : " & Reader.GetValue(2))
            Loop
            Reader.Close
      next
      Con.EndTransaction