public IDatabase CreateInstance(string connectionName)
        {
            IDatabase databaseInstance = null;

            switch (connectionName)
            {
            case "crud":
                databaseInstance = new SqlServerDatabase();
                break;

            case "logging":
                databaseInstance = new OleDBDatabase();
                break;

            default:
                databaseInstance = new NullDatabase();
                break;
            }

            return(databaseInstance);
        }
        private void btnGetDatabase_Click(object sender, EventArgs e)
        {
            Database database;
            if (rdbUseSqlServer.Checked)
            {
                database = new SqlServerDatabase();
            }
            else
            {
                database = new OleDBDatabase();
            }

            DbCommand command = database.Command;
            // now, we can do something, like:
            //command.CommandType = CommandType.Text;
            //command.CommandText = "SELECT * FROM Customers";
            //command.Connection.Open();
            //DbDataReader reader = command.ExecuteReader();

            //reader.Close();
            //command.Connection.Close();
        }
Exemple #3
0
        private void btnGetDatabase_Click(object sender, EventArgs e)
        {
            Database database;

            if (radUseSqlServer.Checked)
            {
                database = new SqlServerDatabase();
            }
            else
            {
                database = new OleDBDatabase();
            }

            DbCommand command = database.Command;
            // now, we can do something, like:
            //command.CommandType = CommandType.Text;
            //command.CommandText = "SELECT * FROM Customers";
            //command.Connection.Open();
            //DbDataReader reader = command.ExecuteReader();

            //reader.Close();
            //command.Connection.Close();
        }