using System;
using System.Data.AccessClient;
using System.Text;
using Medivators.Common;

namespace Medivators.Data
{
	public class Connection : AccessConnection
	{
		//	this guy exists to insure that the application
		//	uses one connection - and only one - throughout
		//	the session. 

		//	Calling code is still responsible for opening
		//	and closing the connection properly!

		#region singleton constructor

		static private Connection _instance = null;		
		private Connection() 
		{
			base.ConnectionString = TextSettings.GetInstance()[Medivators.Common.Enums.SettingTypes.Application, "DataSource"];
			base.Open();
		}
		static public Connection GetInstance()
		{
			if ( _instance == null )
				_instance = new Connection();
			return _instance;
		}
		public override void Open()
		{
			//	static connection never closes. But may need repair
			if (this.State == System.Data.ConnectionState.Broken)
			{
				base.Close();
			}
			base.Open();
		}
		#endregion
	}
}
