Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
6 Months Free & No Setup Fees ASP.NET Hosting!
Search :       Advanced Search »
Home » Visual Studio 2005 » Generic 'T, K' Database Component

Generic 'T, K' Database Component

I have written a C# 2.0 (Visual Studio 2005), Generic Database component, The component has simplified the architecture and the implementation by allowing me to keep the number of overloaded methods to a minimum.

Page Views : 2356
Downloads : 0
Rating :
 Rate it
Level : Advanced
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Team Foundation Server Hosting
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Why did I use Generic <T, K>?

This keeps the number of overloaded methods down to a minimum without using objects. Let me explain.

Method One, without Generic <T, K>:

  1. You would be to have an overloaded method for every type of CONNECTION and DATATYPE.
  2. Because of the different DATATYPES, you would need to rename the methods.
  3. I am sure that you can see that very soon, you have tons of methods and tons of code.
  4. For a developer user of the component this becomes complex.
  5. From a maintenance/enhancement point of view, this becomes tiring and can be costly.

Method Two, without Generic <T, K>:

  1. You have the same methods that I do, but both the CONNECTION and the DATATYPE are cast as objects.
  2. Well we all know that we can have compile issues and usability issues with objects, which is where Generics <T, K> are now part of Visual Studio 2005.

Technical Details of the component

  1. I have replaced the T with CONNECTION and the K with DATATYPE.

  2. When initializing the object, the first parameter, your CONNECTION, can be any of the following types:
    1. A Connection String
    2. A System.Data.SqlClient.SqlConnection
    3. A System.Data.OleDb.OleDbConnection
    4. A System.Data.Odbc.OdbcConnection
    5. An ADODB.Connection
    6. A Oracle.DataAccess.Client.OracleConnection
    7. To name a few...

  3. When Initializing the object, the second parameter, your DATATYPE, can be any of the following types:
    1. A System.String, here your data would be a disconnection XML formatted string, needed by those systems that can only handle strings.
    2. A System.Data.DataSet
    3. A System.Data.DataTable
    4. A System.Xml.XmlDocument

  4. There are four (4) exposed Public Methods, three (3) of them are overloaded:
    1. public DATATYPE Create(CONNECTION, string sql, string tableName)
    2. public DATATYPE Create(string provider, string sql)
    3. public DATATYPE Create(CONNECTION, string sql, string[] parameterList, string tableName, int Timeout)
    4. public void Update(CONNECTION, DATATYPE, string sql, string tableName)

Usage here is when you want to update/insert/etc data utilizing Typed DataSets

 

When the user updates the appropriate line/column


 
After editing the data, the next method called (as highlighted below), will update the table utilizing Typed Dataset. This also works for inserts as well.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
art_scott
Senior Lead Architect/Developer utilizing .NET C# 2.0/3.0, ASP.NET, SQL Server 2005, Reporting Server, .NET 3.0 Workflow, and Web Services. methodologies are Extreme Programming on the Microsoft Enterprise Library utilizing Model View Presenter (MVP). I utilize Visio Architecture to create UML which is then used to update the Team Visual Studio 2005. As the architect and senior/lead developer ensuring design standards, I also train my team on MVP development (WinForms and WebForms), pattern development, C# 2.0/3.0 development and coding as a working in the coding trenches while taking the time to meet with clients on a regular basis and ensuring that our developers are not only being taken care of but excited about our technology and methodologies.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.