Switch to: V10V9V8V7V6V5

API Style Examples

This section contains examples that demonstrate how to control Valentina database using Valentina API commands. Many examples in this section have satellite - example in the section SQL Examples.

Database_Clone example

Demonstrates how you can clone existed database.

Database_EncryptDecrypt example

Demonstrates how to encrypt or decrypt database.

Database_OpenAny example

Demonstrates how to open a database which can be as encrypted so does not. This is required for DBMS kind applications for example.

Database_OpenEncrypted example

Demonstrates how to open and use encrypted database.

Database_Structure_EncryptDecrypt example

Demonstrates how to encrypt or decrypt structure of database.

Database_Structure_OpenAny example

Demonstrates how to open a database which can have structure as encrypted so does not. This is required for DBMS kind applications for example.

Database_Structure_OpenEncrypted example

Demonstrates how to open and use database with encrypted structure.

Dump_SQL_Database example

Demonstrates how you can dump a database into SQL dump file and load dump file file back into Database.

Dump_XML_Database example

Demonstrates how you can dump database into XML file. You can use this example as useful utility to dump any database into XML.

In this example you can play with different options for db.Dump() method:

  • you can choose if to dump database strucutre only, or structure and records or records only.
  • also you can choose if XML file should be formated for easy read, or it should be smaller but unreadable for human eye.

Example also demosn how you can load XML file into a fresh new database. Also note that Valentina can do LoadDump() into existed database appending records. In fact this is not safe way but it works if you know what you do.

Dump_XML_Table example

Demonstrates how you can dump a single table into XML file and load XML file back into Table, even if Table have records. This feature allow you exchange records of single table using XML files.

Field_CreateDrop example

Demonstrates how to create in Table different Field types using command VTable.CreateField() and VTable.DropField().

Field_Find example

Demonstrates how to

  • do VField.Find() on a single value.
  • do VField.Find() on a range.
  • do search NOT a value(s).
  • do search AND on 2 fields.
  • do search OR on 2 fields.

Field_Picture example

Demonstrates how to work with Picture field.

Field_Picture_Compressed example

Demonstrates how to work with Picture field.

Import_Export example

Demonstrates how to export database records into text file, and how to import from text file into database.

IndexByWords example

Demonstrates how to use index by words feature of Valentina with SQL way. It show different kind of searches for string: Start with, Contains, End With…

IndexByWordsWithStyle example

Demonstrates how to use index by words feature AND Index Style feature of Valentina 2.0.

Link_Binary example

Demonstrates how to establish link 1 : M between 2 tables using Valentina model link based on BinaryLink. It creates link using VDatabase.CreateBinaryLink().

Link_ForeignKey example

Demonstrates how to establish link 1 : M between 2 tables using Relational model link based on FOREIGN KEY constraint. It creates link using VDatabase.CreateForeignKeyLink().

Link_ObjectPtr example

Demonstrates how to establish link 1 : M between 2 tables using Valentina model link based on ObjectPtr field. It creates link using VTable.CreateObjectPtr().

Link_ForeignKey_Recursion example

Demonstrates how to establish recursive link on single table using Foreign Key.

Link_ObjectPtr_Recursion example

Demonstrates how to establish recursive link on single table using ObjectPtr field.

Link_Binary_Recursion example

Demonstrates how to establish recursive link on single table using BinaryLink.

Link_ForeignKey_Records example

Demonstrates how to link records of 2 tables if we have ForeignKey link. For this we should simply assign values to PTR field of Many table, which are ID values from One table. On the following picture you can see Tables, Fields and Records that create this example.

person_phone_foreignkey.jpg

Link_ObjectPtr_Records example

Demonstrates how to link records of 2 tables if we have ObjectPtr link. For this we should simply assign values to ObjectPtr field of Many table, which are RecID values from One table. On the following picture you can see Tables, Fields and Records that create this example.

person_phone_objectptr.jpg

Link_Binary_Records example

Demonstrates how to link records of 2 tables if we have Binary link. For this we should simply link pairs of RecID values using VLink.LinkRecords() command. On the following picture you can see Tables, Fields and Records that create this example.

person_phone_binarylink.jpg

Method_Create example

Demonstrates how to create and use Calculated Field (aka Record Method).

Records_AddDeleteUpdate example

Demonstrates how to

  • add records using VTable.AddRecord() command.
  • delete records using VTable.DeleteRecord() command.
  • update records using VTable.UpdateRecord() command.

Records_Sort example

Demonstrates how to Sort records of Table using Table.Sort() method.

Table_CreateDrop example

Demonstrates how to create and drop table using commands VDatabase.CreateTable() and VDatabase.DropTable().

Text_Compressed example

Demonstrates the using of ZIP compression for TEXT (BLOB) field.

Table_Alter example

Demonstrates how to change Table using API way.