Binding View Controls in ADO.NET with NosDB

Ever wondered why the programming world stresses so much on separating your application UI from your business logic? The answer is simple: strongly coupled code decreases code re-usability resulting in excessive code duplication. This can invite disasters; especially for those large systems which are continuously evolving to improve their software quality.

Therefore, programming professionals recommend working with separate layers.  One way to work with separate layers is through data binding.  Data binding refers to synchronizing the data source and the application UI so that any changes in the data source are reflected in the application UI.

The developers of NosDB took this into consideration and included binding view controls in NosDB. NosDB uses an ADO.NET data provider implementation as its data binding solution.

Using ADO.NET with NosDB

So, let’s demonstrate how this works.  Before using the ADO.NET data provider implementation in NosDB, you’ll need to add a few configurations in the app.config/web.config files of your applications.

You can find the NosDB’s ADO.NET data provider at INSTALLATION_DIR\Integrations

In the sample configuration above, note that we have a NosDB specific provider name, Alachisoft.NosDB.ADO.NETProvider, which you will need to explicitly mention in your configurations. In addition, you’ll need  to add the DbProviderFactories tag and the related configuration, as well following the pattern displayed above.

Using Windows Forms

Once you are through with configuring the ADO.NET provider, you can begin working with it. One of the ways is via Windows Forms.

WinForms is an interactive GUI based tool, part of the Microsoft .NET framework, that helps build various kinds of client applications. To use this tool with NosDB, drag-drop a DataGridView from the toolbar to the Controls container in Visual Studio and write code for the OnLoad() method in the code view of the Form Control.

It is recommended that you use the connection in the using block, because your connection will be automatically disposed while exiting this using block.

Executing the code above will result in an output similar to this:


Using ASP.NET Web Forms:

In addition to Windows Forms, you can also use ASP.NET Web Forms to bind view controls with NosDB. ASP.NET Web Forms come with Visual Studio and are part of the ASP.NET web applications framework. Being one of the four programming models used to create web applications, it consists of pages which are accessed via the web browser.

To use ASP.NET Web Forms with NosDB, drag-drop a GridView from the toolbar to the Web Controls container in Visual Studio, and write code for the Page_Load() method.

Again, it is recommended that you use the connection in the using block, because your connection will be automatically disposed while exiting this using block.

Results will be displayed as shown in the screenshot below:

Data Binding

This example marks the end of this short walk through regarding view controls. As you have seen, this blog post shows how NosDB supports binding view controls to allow the data source to sync with the application UI.

Well satisfied? NosDB has a lot to offer its users. You can refer to the official NosDB website to further explore this .NET NoSQL database solution.

Leave a Reply

Your email address will not be published. Required fields are marked *