コード例 #1
0
        public override void Connect(string connectionString)
        {
            if (State != DatabaseConnectionState.Disconnected)
            {
                throw new InvalidOperationException($"Cannot connect when in state {State}");
            }

            try
            {
                State = DatabaseConnectionState.Connecting;

                SqlConnection = new SqlConnection(connectionString);
                SqlConnection.Open();

                ConnectionString = connectionString;
                State            = DatabaseConnectionState.Connected;

                SqlServerDatabaseSystem = new SqlServerDatabaseSystem(this);
            }
            catch /*(Exception ex)*/
            {
                State = DatabaseConnectionState.Disconnected;
                throw; // TODO: Throw library-specific exception and set the InnerException to ex
            }
        }
コード例 #2
0
        public override void Disconnect()
        {
            if (State == DatabaseConnectionState.Disconnected)
            {
                throw new InvalidOperationException($"Cannot disconnect when in state {State}");
            }

            SqlConnection.Close();
            State = DatabaseConnectionState.Disconnected;

            SqlServerDatabaseSystem = null;
        }
コード例 #3
0
 public SqlServerDatabase(SqlServerDatabaseSystem databaseSystem, string name)
 {
     DatabaseSystem = databaseSystem;
     Name           = name;
 }