.net Database Utility Library
| Author |
|
| Company |
joel.net |
| Source Code Available |
Yes |
| License Type |
Free |
| Submitted On |
November 03, 2005 |
| Updated on |
July 25, 2007 |
| .NET Framework |
1.x |
| Cost |
$ 0 |
Description
Accessing your database can be a very repetitive task. This FREE Database Utility (source code included!) class can help reduce a lot of the repetitious code.
This library will work in any .net or asp.net project; using C#, VB.net or any other .net language.
- Full MSDN Style HTML documentation with example code.
Html Documentation can be located at http://joel.net/docs/DatabaseUtility.
- Works in ANY .net project
C#, VB.NET, ASP.NET or any other supported .Net language, this library will work!
- Retreive a DataTable with only one command!
You no longer have create a SqlDataAdapter and call the Fill() method to fill your DataTable. From retreiving a DataTable, SqlDataReader, Scalar or
simply executing a NonQuery, you can do it all with only one command.
- No need to Open and Close your connection object.
The SqlConnection object will automatically be Opened (if closed) and Closed at the end (if closed when calling method).
If SqlConnection object is Open when calling the method, the SqlConnection object will be left open.
The SqlConnection object will automatically be closed (if closed when calling method) with a SqlDataReader object when calling SqlDataReader's Close() method.
- All input variables for methods are identical.
Changing your code to return a Datatable instead of a SqlDataReader is now super easy.
- 15 overrides for each of the 4 methods.
The control has 4 methods ExecuteDataTable, ExecuteNonQuery, ExecuteReader, ExecuteScalar each with 15 overrides -- that's a total of 64 methods!
- Global Connection's can be used in your project
- Write less code.
- Much much more
Go to // Retrieve DataTable from database (Global SqlConnection is automatically Opened and Closed!)
DataTable table = DatabaseUtility.ExecuteDataTable("SELECT * FROM Customers");
OR
// Retrieve SqlDataReader from database (Global SqlConnection is automatically Opened and Closed!)
SqlDataReader reader = DatabaseUtility.ExecuteDataReader("SELECT * FROM Customers");
while (reader.Read()) { /* ... */ }
reader.Close();
OR
// Retrieve DataTable from database (SqlConnection is automatically Opened and Closed!)
DataTable table = DatabaseUtility.ExecuteDataTable(
new SqlConnection("Data Source=localhost;User ID=sa;Password=password"),
"SELECT * FROM Customers"
);
OR
// Retrieve DataTable from database (SqlConnection is manually Opened and Closed!)
SqlConnection connection = new SqlConnection("Data Source=localhost;User ID=sa;Password=password");
connection.Open();
DataTable customersTable = DatabaseUtility.ExecuteDataTable(connection, "SELECT * FROM Customers");
DataTable productsTable = DatabaseUtility.ExecuteDataTable(connection, "SELECT * FROM Products");
connection.Close();
Reviews
Submit a review