GitHub    Download    Forum
Overview
Tutorial
Database setup
Preparing the project
Establish the connection
Shut down the connection
DTDL types
Creating the schema
DADL classes
Entry point object
Write and read attributes
Write and read lists
Extending the schema
Modified entry point object
Write and read objects
Write and read object lists
C++ API
C# API
DTDL
DADL
Setup
C++
C#

Shut down the connection

When you wish to terminate an interaction with the storage on a server, the following functions will be needed. Again, we'll pack them all into their own function, called 'uninit'.
Now, we just need to call that function at the end of our main function as follows:
Tutorial.cpp – main function
Tutorial.cs – main function
uninit(pDomain, ulStorageId);
uninit(pDomain, ulStorageId);
First of all, we unbind all types of our DADL file with "Unbind". Then we release our storage and disconnect all connectionsrelease our storage and disconnect all connections. After that, we uninitialize the domain and delete ituninitialize the domain and delete it.
Last but not least, we uninitialize the threaduninitialize the thread.
uninit.cpp
uninit.cs
#include "pch.h"

void uninit(WDomain*& pDomain, UINT32 ulStorageId)
{
	// unbind from schema
	AccessDefinition::Unbind();

	// disconnect from storage
	pDomain->ReleaseStorage(ulStorageId);

	// disconnect from server
	pDomain->DisconnectAll();

	// give more time for cleanup (prevents false error messages from the debugger)
	::Sleep(400);

	// delete domain object
	pDomain->Uninitialize();
	Domain_Destroy(pDomain);

	// uninitialize thread and free libraries
	UninitializeThread();
}
using System;
using DataFoundationAccess;

namespace TutorialCs
{
	partial class Tutorial
	{
		public static void uninit(WDomain pDomain, UInt32 ulStorageId)
		{
			// unbind from schema
			AccessDefinition.Unbind();

			// disconnect from storage
			pDomain.ReleaseStorage(ulStorageId);

			// disconnect from server
			pDomain.DisconnectAll();

			// give more time for cleanup (prevents false error messages from the debugger)
			System.Threading.Thread.Sleep(400);

			// delete domain object
			pDomain.Uninitialize();
			WDomain.Destroy(pDomain);

			// uninitialize thread and free libraries
			ThreadInit.UninitializeThread();
		}
	}
}
Now we know how to initialize and uninitialize DataFS libraries and connections. In the next steps, we will define the schema types we want to write to the database.
© 2022 Mobiland AG