I have several other SQL commands using NpgSQL all working correctly. Commands like INSERT INTO and DELETE FROM.
However, within the same project, and the same code, I can not get a database to order itself using ORDER BY. If I run the command within Bit.io, it works. Once I copy and paste the command into my C# project, it does not have the correct behavior.
using var con = new NpgsqlConnection(connectionString);
con.Open();
String sql = "SELECT * FROM databaseName ORDER BY columnName";
NpgsqlCommand command = new NpgsqlCommand(sql, con);
command.ExecuteNonQuery();
con.Close();
It is supposed to order columnName in databaseName alphabetically, but what happens is the database is ordered seemingly in an arbitrary way each time that has no relation to the colunn.
If I run ONLY the command SELECT * FROM databaseName
, the same behavior occurs.
The code does not have compilation or runtime errors.