The "Best Answer"

How Can Testing Be Bad?

An imaginary programming test question
This is how I would answer the question if the question was part of a real job.

There are clearly some styling practices that are not flavour of the month.
  • Variable names prefixed with their type because it is helpful for others.

  • Variables declared at the top of the function as declarations near their first use hide code functionality.
There is an unnecessary string assignment for the SQL statement.

All resources are released and there is a try/catch block.

Because It is My Way!

This is my prefered method because it has the data access in a separate layer without any unnecessary intermediate code or files and no run time interpretation that is also version dependent.
With a whole lot of caveats I would regard this as the best answer as it is the closest of the three answers to being ready to put into a live system.

It is also the closest to how I would do it, hence the problem with tests.

It's the best ways because it is my way and it adds all the little details that I expected to see but the question didn't actually specify.

Answer C#

    protected Boolean LoadDataAnswer1(String strConnectionStringLocal,DataTable dtInteresting)
        Boolean boolRes = false;
        String strSQL;
        SqlConnection connSQL;
        SqlCommand cmdSQL;
        SqlDataReader drSQL;

            // Load the datatable with the relevant tickers
            using (connSQL = new SqlConnection(strConnectionStringLocal))
            using (cmdSQL = new SqlCommand())
                // Main Select
                strSQL = "[spSelect tab_StockTickers1]";
                cmdSQL.Connection = connSQL;
                cmdSQL.CommandText = strSQL;
                cmdSQL.CommandType = CommandType.StoredProcedure;
                cmdSQL.CommandTimeout = 3600;
                cmdSQL.Parameters.AddWithValue("@ShareIndex", "FTSE 100");

                // Create a datatable for the results
                dtInteresting = new DataTable();

                // Load datatable from an SQL Datareader
                using (drSQL = cmdSQL.ExecuteReader())
            boolRes = true;
        catch (Exception ex)
        return boolRes;

Answer SQL

USE StockTickers

IF OBJECT_ID('spSelect tab_StockTickers1') IS NOT NULL DROP PROCEDURE [spSelect tab_StockTickers1]

Selects core information about a company and its stock market details

1.00    Ian Smith   26/Jun/2020 Original
CREATE PROCEDURE [spSelect tab_StockTickers1]
@ShareIndex VARCHAR(32)

SELECT Company,
  FROM StockTickers
WHERE ShareIndex = @ShareIndex 

Other Interesting Pages On Some Of My Sites.
Weight Loss Calculator
Screen shot of weight loss calculator Weight Loss Calculator Tries to simulate the body and report the effects of food and exercise in periods as short as 15 minutes.

This level of detail highlights the effects of a run, bike ride or chocolate bar.

For those who are new to exercise, weight fluctuation due to glycogen usage is made much clearer.
Initial Programming Language
IPL Screen shot Initial Programming Language possibly the easiest way to learn programming on a Windows computer.

Designed to mimic the simplicity of the 1980s home computers where you could get started in minutes...

...but still powerful enough to do pretty complex things.
Learn To Budget
Money Manager Screen shot Learn To Budget MoneyManger.ipl is a free, MS Windows based, computer program that can be used with children and young adults to practice budgeting

Put simply you get paid once a week, you then spend this money on food, rent etc. If you do just this, then you will be able to save some money and then buy cars, holidays etc.
Please note that these links do not use any tracking cookies or similar technology.