Click here to Skip to main content
15,897,891 members
Articles / Programming Languages / C#

An ADO.NET multi-database, multi-tier solution

Rate me:
Please Sign up or sign in to vote.
3.78/5 (26 votes)
9 Mar 2004CPOL8 min read 110.3K   4.3K   96  
A view of how ADO.NET can be used in a multi-database, multi-tier environment.
using System;
using System.Data;

namespace MultiTier.Data {

	public abstract class DataTier {

		private DataTable dtDataTable;
		private Exception exException;
		private long lngAffectedRecords;
		private string strConnectionString;
		private string strTableName;

		private DataTier() {
		}

		protected DataTier(string connection) {
			this.ConnectionString = connection;
			this.ConstructDataAdapter();
		}

		protected DataTier(string connection, string tableName) {
            this.ConnectionString = connection;
			this.TableName = tableName;
			this.ConstructDataAdapter();
		}
		
		protected DataTable Table {
			get { return dtDataTable; }
			set { dtDataTable = value; }
		}

		public string ConnectionString {
			get { return strConnectionString; }
			set { strConnectionString = value; }
		}

		public string TableName {
			get { return strTableName; }
			set { strTableName = value; }
		}

		public long AffectedRecords {
			get { return lngAffectedRecords; }
			set { lngAffectedRecords = value; }
		}

		public Exception Exception {
			get { return exException; }
			set { exException = value; }
		}

		protected abstract void ConstructDataAdapter();

		public abstract DataTable ReadData();

		public abstract void SaveData(DataTable dataTable);

		public abstract void InitializeConnection();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Belgium Belgium
I started using C# in the spring of 2003.
For the moment I'm working for a company that makes healthcare related software and do the ASP.NET programming in C# and VB.NET.

Comments and Discussions