 |
Introduction
The release of the .NET Platform is complimented with the release of
ADO.NET the new API to access databases on the .NET Platform. ADO.NET
has a concept of Managed Data Providers. A Managed Provider is a group of
objects that allow you to access a particular database or a particular
type of data sources. Managed Providers help you to gain the maximum
performance out of your data source. The .NET Framework by default
carries two Managed Providers, the SQL Managed Provider to deal
specifically with the Microsoft SQL Server and OleDB Managed
Provider to deal with data sources having OleDb connectors. A third,
Odbc Managed Provider was released separately available from
here, built specially to deal with data sources having ODBC
drivers. CodeCharge Studio support the usage of all three above
mentioned Managed Providers. Since all vendors are free to create
their own Managed Providers to interface their data source better,
more Managed Providers will be released, and its not possible to
address them all. May be the popular Managed Providers will get added
into CodeCharge Studio going forward. But basically since most data
sources have either a OleDb or ODBC connector you should not face
problems interfacing any of them through CodeCharge Studio.
Selecting the Managed Provider in CodeCharge Studio
Its utmost important to use the right Managed Provider for your data
source so that our applications works correctly as well as we get
the maximum performance from our application. For example while using
MS SQL Server as the database we should always use the SQL Managed
Provider since it uses direct binary streams to communicate with the
database giving us maximum performance.
By default CodeCharge Studio uses the OleDb Managed Provider to
connect to the data source. The choosing between different Managed
Providers is done while creating a new database Connection in
CodeCharge Studio.
Configuring a database Connection
Create a new Blank Project or Open an existing project in CodeCharge
Studio. Go to the Project Explorer, right-click Connections tab and
select New Connection from the context-menu. The same New Connection
dialog is opened even if when we using Application Builders or editing
any of the previously created Connections.

Figure 1: New Connection dialog
In figure 1 above, we can see that the Connection Name textbox is used
to enter the name of the connection, this is used by the code
generated by CodeCharge Studio. The Database dropdown list is very
important, since every database differs a little bit in the syntax of
query strings, data types etc. we need to set the correct Database
here. Then we have a choice to either select a ODBC Data Source or a
custom Connection String. In the above screen we have setup a
connection to a MS Access database using the OleDB connection string.
These steps are enough to configure a normal database connection which
uses the OleDb Managed Provider. In case we want to use the other
Managed Providers, follow the next steps.Configuring a server
database connection
CodeCharge Studio, gives us the flexibility of defining two ways to
connect to your database i.e. we can define a connection string to be
used by CodeCharge Studio while creating our application and
optionally we can
specify an additional connection string to be used on the server where
we publish
our Web Application. Of course the database schema referenced by both
the connection strings should match else our application will
malfunction. Hence remember if a database schema is changed the same
change should be propagated to the other database also, in case you
are using two separate connection strings.
Switch to the Server tab in the Add New Connection dialog as shown
in figure 2. By default the server-side database connection is
configured to use the same connection string used while designing our
application (indicated by the selected Same as Design checkbox).

Figure 2: Server tab of Connection dialog Uncheck the Same as
Design checkbox and then select the appropriate Managed Provider we
want to use and set the connection string. In the figure 3, below we
have setup the SQL Managed Provider Connection string, so now
CodeCharge Studio will use the SQL Managed Provider to conduct all the
database communication. Similarly, you can setup an ODBC Managed
Provider too, but remember the ODBC managed provider is not installed
with the .NET Framework and you need to install it before you can use
this provider in CodeCharge Studio.

Figure 3: SQL Managed Provider Also notice in the figure 3 above we
have Date Format and Boolean Format dropdown's. If your database
requires these data types to be parsed in an particular format, may be
depending on your locale; Set these fields up to affect all the SQL
queries generated by CodeCharge Studio.Conclusion
In this article we have learnt how to configure CodeCharge Studio to
use the right .NET Managed Data Provider for your Web Application to
give you maximum performance. Plus we learnt to setup database specific
Date and Boolean type formatting schemes.
|
 |