Web Development principles, concepts and ideas in C# and PHP...
logo  
MSN Search

Documentation

In order to install and use the DatabaseHandler, you need to follow a few easy steps:

Step 1

add the DatabaseHandler.dll assembly file to your project references.
If you want to use the .Net DatabaseHandler 1.1 with MySQL, make sure to add the file MySql.Data.dll to the project references too. The file MySql.Data.dll is available in the .Net DatabaseHandler 1.1 download file.

Step 2

In the class where you want to use the DatabaseHandler, make sure to add the following "using" statement:

using DatabaseHandler;

Step 3

instantiate the data provider with the database type and the correct connection string.

  • For MS Access:  Provider provider = new Provider("MS Access", "connection string");
  • For MySQL:   Provider provider = new Provider("MySQL", "connection string");
  • For MS SQL Server:   Provider provider = new Provider("MS SQLServer", "connection string");

Step 4

use one of the supported methods to handle database data.

  • int provider.GetIntValue(command);
  • string provider.GetStringValue(command);
  • bool provider.ExecuteNonQuery(command);
  • object provider.GetDataReader(command);
  • DataSet provider.GetDataSet(command);

Currently the DatabaseHandler supports only MS SQL Server, MySQL and MS Access databases and the above described methods. Internally, the DatabaseHandler uses the System.Data.SQLClient for MS SQL Server, MySql.Data for MySQL and System.Data.OleDb for MS Access.

In the case of the method GetDataReader(command), the returned object must be casted into the needed type:

  • To get a MS SQLServer DataReader:  SqlDataReader reader = (SqlDataReader)provider.GetDataReader(command);
  • To get a MySQL DataReader:  MySQLDataReader reader = (MySQLDataReader)provider.GetDataReader(command);
  • To get MS Access DataReader:  OleDbDataReader reader = (OleDbDataReader)provider.GetDataReader(command);

The "command" variable can be a OleDbCommand, SqlCommand or MySqlCommand, depending if you are using MS Access, MS SQL Server or MySQL respectively.

Pay attention to the way parameters are used with the different Command classes. While MS Access and MS SQL Server use @parametername, MySQL uses ?parametername.

 

.Net DatabaseHandler 1.1

 

For more information, please refer to the .Net DatabaseHandler 1.1 documentation available in the file to download or use the email contact@webdp.net.

Download DatabaseHandler 1.1