Click here to Skip to main content
Licence 
First Posted 19 Jan 2007
Views 21,502
Bookmarked 17 times

Database manager

By | 19 Jan 2007 | Article
A usefull tool to control the database, easy to use and easy to control.

Introduction

Using the DbConnection, DbDataAdapter and DbCommand makes the code very long and not easy for the eyes.

This class will make it easy to work with arround DataBases, and will shorten the code in atleast 4 more lines for every command.

A simple example

System.Data.DbManager DbMgr = new System.Data.DbManager("System.Data.OleDb", connstring);
DataTable dtUsers = DbMgr.Retrieve("Select * From tblUsers");
String TopUser = DbMgr.Scalar("Select Top 1 UserName From tblUsers").ToString();
DbMgr.Execute("Delete * From tblUsers");

This will create a new DbManager instense with the OleDb data type, return the tblUsers table, return to top first username and will delete all from tblUsers table.

This is done in here in 4 lines where without it, it would have taken atleast 10 lines.

How it works

In every command that is needed to be done by the class, it opens and closes the connection, this to make sure that the connection will stay closed at all times, so that other connections can be made to that source.

To get a more information on how it works you are welcomed to look at the source code.

Creating your own manager

The usage of this class could be done in alot of the data types such as OleDb, Odbc, SqlClient etc., but if you have a problem with it, you are welcomed to create your own manager class, and can derive from the IDbManager interface.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

NaNg15241

Web Developer

Israel Israel

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 4 PinmemberMomano4:55 13 Jul '10  
Generaldiploma thesis Pinmembercccp145:38 24 Feb '10  
Questionhow to use update method to insert PinmemberMember 27434151:15 3 Jan '08  
GeneralUpdate method does not work... PinmemberCabbi3:25 22 Jan '07  
GeneralRe: Update method does not work... PinmemberNaNg152416:33 22 Jan '07  
NewsRe: Update method does not work... PinmemberNaNg152416:56 23 Jan '07  
GeneralGood Idea but... PinmemberCabbi3:45 19 Jan '07  
GeneralRe: Good Idea but... PinmemberNaNg1524120:04 19 Jan '07  
NewsRe: Good Idea but... PinmemberNaNg152414:32 20 Jan '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 19 Jan 2007
Article Copyright 2007 by NaNg15241
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid