Ejemplo n.º 1
0
        private void OpenSqlServerConnection()
        {
            InitializeDataConnection();

            switch (DataConnection.State)
            {
            case ConnectionState.Broken:
                DataConnection.Close();
                DataConnection.Open();
                if (!DataConnectionInfo.IsAcceptableVersion(DataConnection))
                {
                    DataConnection.Close();
                    DataConnectionInfo.ThrowVersionException();
                }
                break;

            case ConnectionState.Closed:
                DataConnection.Open();
                if (!DataConnectionInfo.IsAcceptableVersion(DataConnection))
                {
                    DataConnection.Close();
                    DataConnectionInfo.ThrowVersionException();
                }
                break;
                //default:
                //    break;
            }
        }
Ejemplo n.º 2
0
        private void InitializeDataConnection()
        {
            if (DataConnection != null)
            {
                return;
            }

            DataConnection = DataConnectionInfo.CreateDbConnection();
        }
Ejemplo n.º 3
0
 public void ChangeDataConnectionInfo(DataConnectionInfo dataConnectionInfo)
 {
     Close();
     DataConnectionInfo = dataConnectionInfo;
     InitializeDataConnection();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes the connection with our custom connectionInfo for whatever
 /// type of database we want to connect to. For now it is SqlServer only.
 /// </summary>
 /// <param name="dataConnectionInfo">IDataConnectionInfo compatible object</param>
 public DataConnectionManager(DataConnectionInfo dataConnectionInfo)
 {
     DataConnectionInfo = dataConnectionInfo;
     InitializeDataConnection();
 }