Introduction
This C# class library can be used to simplify database connection code used by your application. It provides many high performance and well tested methods that are commonly used when interacting with databases.
Includes commonly used database methods such as:
Open()
Close()
TestConnection()
Execute()
Fetch()
UpdateData()
InsertData()
InsertAutonumRecord()
DeleteData()
ListTables()
Background
As a senior developer for over 15 years, I have found that high performance reusable code is highly effective when creating applications. There is no need to start from scratch for many well known technologies. I have used this library many times, and it has proven to be effective and saves time. Enjoy!
Using the Code
The below sample code can be used in your application to open a database connection and perform some basic operations.
Make sure you add a project reference to the "ADODBLib
" class library project included in this article.
ADODBLib.DBConnection conn = new ADODBLib.DBConnection
("Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password = myPassword; ");
string result = conn.Open();
if (result == null)
{
System.Diagnostics.Debug.WriteLine("db open succeeded");
System.Data.DataTable fetch = conn.Fetch("select * from table1");
if (fetch != null)
{
System.Diagnostics.Debug.WriteLine("db fetch succeeded. row count = " + fetch.Rows.Count);
}
else
{
System.Diagnostics.Debug.WriteLine("db fetch succeeded");
}
string execute = conn.Execute("delete from table1 where id = 1");
if (execute == null)
{
System.Diagnostics.Debug.WriteLine("db execute succeeded");
}
else
{
System.Diagnostics.Debug.WriteLine("db execute failed. " + result);
}
conn.Close();
}
else
{
System.Diagnostics.Debug.WriteLine("db open failed. " + result);
}
History
ADODBLib
version 10.0.0.0