Here's one I created and have been using for the past 3 years in production
environments that receive ~3 million requests /day and work just fine.
Know this, I started out intending to bake in support for all the major db
provides (SqlServer, Oracle, OleDb, and Odbc). In the end, SqlServer has
the greatest completeness since its what I use daily. The others are
missing only the "MapToDbType(...)" function implementation. It supports
asyncronous command execution (even since before ADO.NET 2.0 was announced),
ADO.NET Transactions, and about everything else you'd expect from a simple
data access wrapper.
I decided, once the original data access application block was released to
avoid the DAAB because to use it requires more code than I'm comfortable
with and forces me into situations that I sought to avoid with this DAL.
This component doesn't support transaction in async commands, simply because
it isn't possible to execute multiple commands on the same
connection/transaction simultaneously. Even in ADO.NET 2.0, their own
support for this doesn't do so, it does some sort of transaction weaving to
make it work but I'm not sure how to do that in my own code. Anyway, this
code has been around much longer than even the DAAB and ADO.NET 2 were ever
announced.
Actually, this DAL is slightly older than my current one, my current one
targers 2.0 and so is different than this but if you're interested let me
know. This requires VS.NET 2003 (because of the project file).
Ultimately, you simply say:
using Zen.Data;
using Zen.Data.SqlClient;
public void x()
{
SqlClient data = null;
DataTable result = null;
try
{
data = new SqlDataHelper(connectionString);
result = data.ExecuteTable("select * from orders", false);
// or...
int orderNumber = 12345;
int value = 0;
data.AddParameter("@Value1", DataType.Integer, orderNumber);
data.AddParameter("@Value2", DataType.Integer,
ParameterDirection.Output, value);
result = data.ExecuteNonQuery("usp_GetStatusCodeForOrder", true);
value = data.GetParameterValue("@Value2");
// or...
IAsyncResult iaResult = data.BeginExecuteTable("select * from
generalledger", false);
// so some stuff while fetching records
data.BeginExecuteReader("select * from auditlog", false, new
AsyncCallback(CallbackMethod));
// do some more stuff while fetching records
result = data.EndExecuteTable(iaResult);
}
finally
{
if (data != null)
{
data.Dispose();
}
}
}
public void CallbackMethod(IAsyncResult ar)
{
SqlDataHelper data = null;
IDataReader result = null;
int count = 0;
try
{
data = new SqlDataHelper("ConnectionString");
result = data.EndExecuteReader(ar);
while (result.Read()) count++;
MessageBox.Show("Callback: " + count.ToString());
}
catch (Exception ex)
{
throw;
}
finally
{
if (data != null)
{
data.Dispose();
}
}
}