C# 我如何颠倒顺序给我最小的而不是最大的?
下面的方法有一个命令,可以在文本框中打印出数据库中的行。它只打印行的maxDataBaseListings。但是,它会从最早的日期打印到最新的日期。如果maxDatabaseListings为10,并且我的第11个条目的日期比第10个条目的日期新,则不会显示该条目 如何通过命令反转顺序以首先显示最新日期?这样,当调用该方法时,它将刷新首先列出最新日期的表C# 我如何颠倒顺序给我最小的而不是最大的?,c#,sql,group-by,sql-order-by,C#,Sql,Group By,Sql Order By,下面的方法有一个命令,可以在文本框中打印出数据库中的行。它只打印行的maxDataBaseListings。但是,它会从最早的日期打印到最新的日期。如果maxDatabaseListings为10,并且我的第11个条目的日期比第10个条目的日期新,则不会显示该条目 如何通过命令反转顺序以首先显示最新日期?这样,当调用该方法时,它将刷新首先列出最新日期的表 public void refreshListing(TextBox inputTextBox, TextBox inputMaxDataba
public void refreshListing(TextBox inputTextBox, TextBox inputMaxDatabaseListings)
{
if (currentlyConnectedToADatabase)
{
maxDatabaseListings = returnMaxListings(inputMaxDatabaseListings.Text, numberOfDatabaseListings);
inputTextBox.Text = "";
cnn.Open();
//COMMAND HERE
command = new SqlCommand("SELECT * FROM tcn.Demo ORDER BY DateTimeOfInsertion, SomeNumber, SomeText, AnotherNumber", cnn);
reader = command.ExecuteReader();
theTextBox = inputTextBox;
int i =0;
if (reader.HasRows)
{
while (reader.Read() && i < maxDatabaseListings)
{
string printString = int.Parse(reader["SomeNumber"].ToString()) + " " + reader["SomeText"].ToString() + " " + int.Parse(reader["AnotherNumber"].ToString()) + " at " + reader["DateTimeOfInsertion"].ToString() + Environment.NewLine;
theTextBox.AppendText(printString);
i++;
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
cnn.Close();
}
else
{
MessageBox.Show("You must first connect to a database!");
}
}
使用降序:按[FieldName]DESCwow排序,这比我想象的要简单得多,谢谢!欢迎你,每个人都会有第一次
ORDER BY column_1 DESC, column_2, column_n