The ADO.NET Driver for NuoDB enables you to develop .NET applications that connect to the NuoDB CDMS. It is a fully managed ADO.NET driver, written in C# for .NET 3.5, implements all the required ADO.NET interfaces and integrates with ADO.NET aware tools.
Included in the driver is a plugin for Visual Studio 2010 and 2012 that acts as a DDEX (Data Designer Extensibility) provider. By means of this plugin, you can browse the content of a NuoDB database and manipulate the data contained therein.
- NuoDB 1.1 (minimum version required)
- Visual Studio Professional 2010/2012
- .NET Framework v4 or later.
The ADO.NET driver for NuoDB is bundled with the main NuoDB Installer and automatically registers the .NET assembly, declares the database provider, and installs the Visual Studio plugin in the available IDEs.
Integration with Visual Studio IDE
The DDEX plugin for Visual Studio Professional 2010/2012 is automatically installed with the ADO.NET Driver for NuoDB, The plugin enables you to work with the driver from within the familiar IDE interface.
To connect to a NuoDB database:
- From the Server Explorer panel in Visual Studio, right-click the Data Connections node and select Add Connection.
The Change Data Source dialog appears.
If the Server Explorer panel is not visible, you can open it from the View > Server Explorer menu.
- From Data Source, choose NuoDB Database; and in Data Provider, choose .NET Data Provider for NuoDB; then click OK.
The Add Connection dialog appears.
- Configure the connections settings:
- Broker Address: DNS or IP address of the machine were the broker is running
- Database: Name of your NuoDB database
- Username: Username for the connections
- Password: Password for the username
- Default Schema: Name fo the schema to connect to
- Click Test Connection to test your configuration; then click OK to finish.
Binding a Data Source to a Windows Form DataSet
- From within a Windows Form project, open the Data Sources view (Data > Show Data Sources)
- Click the Add New Data Source toolbar button.
The Data Source Configuration Wizard opens.
- Walk through the Data Source Configuration Wizard dialog:
- Choose Database > Next;
- Choose Dataset > Next;
- Accept the default data connection option ([ localhost (test) ] > Next;
- Accept the Save the Connection String to the Application Configuration File default > Next;
- Select which tables you want to import into the DataSet and click FInish. (As a test, choose HOCKEY.)
The solution updates to include the new DataSet and Data Sources view.
Create a Form or other Database Object
- In the Data Sources view,select the HOCKEY node under the testDataSet and drag it on the form preview. A new Data Grid View object is created, along with the objects implementing the binding between the visual form and the NuoDB database.
Other objects could also be created by selecting from the drop-down list invoked from the arrow button to the right of HOCKEY.
- Compile and run the application. The HOCKEY table form appears.
Binding a Windows Form using Entity Framework
The first step to be done is hence creating native .NET objects replicating the data structures found in the NuoDB database.
- Right click the application node in the Solution Explorer, and select Add > New Item.
- From the Data category of the installed templates, select ADO.NET Entity Data Model,
- Name the new file as HockeyModel.edmx
The Entity Data Model Wizard appears.
- Walk through the Entity Data Model Wizard:
- Select Generate From Database > Next;
- Select an existing connection (coming from the project settings or from the Server Explorer connections) or make a new one, > Next;
- Select the table you want mapped into native objects > Finish.
After the wizard is dismissed, the *edmx tab displays a diagram of the new entities, and the Data Sources view will have a new data source.
To add form components to the Entity Frameworks model:
- In the Data Sources view, click the Add New Data Source toolbar button.
The Data Source Configuration Wizard appears.
- Select Object from the list of choices, then click Next.
Expand the structure of the application and select the HOCKEY type that the Entity Framework wizard has created to model the HOCKEY table in the database, then click FInish.
Once the wizard is finished, the Data Sources view will contain a new HOCKEY top-level entry; selecting this node and dragging it on the Windows Forms will create a new Data Grid View.
This new grid control must be populated by writing some custom code; double-click on the form to open the code window, and change it to include a reference to the newly defined testEntities, binding its HOCKEY property to the DataSource property of the new data grid object.
Running the modified code will show two Data Grid controls bound to the same database, using the two different binding technologies.
Using LINQ to Query the Database without using SQL Statements
Instead of binding an entire table to the grid control, the user can filter the data by writing a LINQ statement, for instance:
Running the modified program will display in the lower grid control only the two players that play as goalkeeper, by running a SQL statement dynamically-generated from the LINQ syntax.
The ADO.NET driver for NuoDB can be used directly from any VB.NET, C# or Managed C++ application. After adding the NuoDb.Data.Client.dll to the list of referenced assemblies, the user can write standard ADO.NET client code like this:
An application can also avoid the need to bind explicitly to a single ADO.NET provider, and selecting it at runtime via the DbProviderFactory functionality. In this case the manipulation of the data will occur only via the standard interfaces defined by ADO.NET.
Connection String Definition
When using the ADO.NET driver for NuoDB directly, the configuration is specified in a single connection string.
Options in the configuration string are separated by a semi-colon character ‘;’. Inside each option, the name of the option is separated by its value by a ‘=’ character. White spaces around the name and the value are ignored. If the value of an option contains a semi-colon, or must include spaces at the beginning or at the end, it should be enclosed in single or double quotes.
The list of recognized options are:
|Server||The address of the NuoDB broker, in the form hostname[:port]|
|Database||The name of the database (i.e. chorus) to open|
|User||The name of the DBA user|
|Password||The password of the DBA user|
|Schema||The schema to be used by default (optional). If the schema is not specified, all the tables in the SQL queries must be fully specified, e.g. HOCKEY.HOCKEY|
Uninstalling the ADO.NET Driver
To uninstall the driver:
- Open the Control Panel and select the Uninstall Software option.
- From the list of installed program select the “ADO.NET Driver for NuoDB” and click Uninstall.
NuoDB® Company Website
Copyright © 2013 NuoDB, Inc. All rights reserved