Document database is a kind of way to store the extension data in the document. It is not visible to the end user. The data is organized in a format of SQL database and follows the SQL syntax. So you will feel much comfortable if you are familiar with SQL. In case, you are not skillful, here is one link I think it may help you to get started with SQL.
We have a very good sample in SDK \api\NET\examples\Basic Examples\CSharp\WPF\DatabaseDockPane\. In this article, I'd like to get through the relevant objects and basic usage of the database.
copyright belongs to image source: www.filemakerstudio.com.au
Every document has a property Document.Database which is a object type DocumentDatabase. It is the main entry of the relevant APIs. The database can contain many tables. It supports the common usages of database: Create, Add, Query, Modify, Delete.
- NavisworksCommand: derives from .NET DbCommand. It represents an SQL statement or stored procedure to execute against a data source. It provides a base class for database-specific classes that represent commands.
- NavisworksDataAdapter: derives from .NET DbDataAdapter . It inheritors of DbDataAdapter implement a set of functions to provide strong typing, but inherit most of the functionality needed to fully implement a DataAdapter .
- NavisworksConnection: derives from .NET DbConnection. It represents a connection to a database.
- NavisworksTransaction: used to manipulate the transction of database.
Let us take a look how to create a table:
//get document database
DocumentDatabase database =
// use transaction. The type for creation is Reset
using (NavisworksTransaction trans =
//setup SQL command
NavisworksCommand cmd = trans.Connection.CreateCommand();
//creation of SQL syntax
string sql = "CREATE TABLE IF NOT EXISTS order_test("+
"count INTEGER DEFAULT 1,"+
"price CURRENCY DEFAULT 100.55)";
cmd.CommandText = sql;
// do the job
//submit the transaction
By this code, we created a table named "order_test". It has three columns:
item_name: which is a Text
count: which is an integer
price: which is a currency (double)
In the next post, we will see how to fill in the table and query it.