cdbldemo demonstrates database APIs and performs the following
-
Creates or opens a access database by ODBC, and create table "MSFORMS".
-
Creates table MSCATALOG for database operations in microstation.
-
Create table "SHAPES";Scan the active model, for each closed shape or complex shape in the model, then create a row in the database recording the area of the shape in the database, and add a linkage to the element associating it with the entry in the database.
-
Pick one shape in the active model, and show a message which display the area of the shape. The area value is from the database.
-
Disconnect the database.
In order to build cdbldemo(Create a database and add linkages demo), Visual Studio 2013 is required and the MicroStation developer batch file must also have been set. It is recommended to first run the Visual Studio 2013 command prompt "VS2013 x64 Cross Tools command prompt" and then run the MicroStation SDK command MicroStationDeveloperShell.bat.
This example provides the following key-ins.
-
CDBLDEMO CREATECONNECTDB: Create and(or) connect to a database by ODBC.
-
CDBLDEMO CREATEMSCATALOG: Create table MSCATALOG.
-
CDBLDEMO SAVEINFOTODB: Save area info of shapes to database
-
CDBLDEMO CHECKSHAPE: Start CheckShapeTool to check shapes area from database.
-
CDBLDEMO DISCONNECT: Disconnect the database.
File "shapes.dgn" is published for this example. It is in the folder of this example
The steps for creating a new access database by ODBC:
-
Keyin CDBLDEMO CREATECONNECTDB, then pop up the dialog "Select Data Source".
-
Change to "Machine Data Source" page.
-
Click "New..." button.
-
Click "Next" after choosing the type of data source.
-
Select driver "Microsoft Access Driver(*.mdb, *.accdb)" and click "Next".
-
Click "Finish", then dialog "ODBC Microsoft Access Setup" is popped up.
-
Click "Create..." button in the dialog "ODBC Microsoft Access Setup", then dialog "New Database" is popped up.
-
Select a folder and input a new name like "new.mdb" in the text control below the label "Database Name". Click "OK" button, then the new database file is created.
-
Input Data Source Name in dialog "ODBC Microsoft Access Setup", and click "OK" button.
-
Click "OK" button in the dialog "Select Data Source", then the new database has been connected by MicroStation.