这是一个示例代码,用于从表中选择所有记录。有人可以告诉我如何选择该表的最后一条记录吗?
select * from table
当我使用时:出现SELECT * FROM TABLE ORDER BY ID DESC LIMIT
此错误:第1行:“ LIMIT”附近的语法不正确。这是我使用的代码:
private void LastRecord()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HELPDESK_OUTLOOKConnectionString3"].ToString());
conn.Open();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("SELECT * FROM HD_AANVRAGEN ORDER BY " +
"aanvraag_id DESC LIMIT 1", conn);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
TextBox1.Text = (myReader["aanvraag_id"].ToString());
TextBox1.Text += (myReader["wijziging_nummer"].ToString());
TextBox1.Text += (myReader["melding_id"].ToString());
TextBox1.Text += (myReader["aanvraag_titel"].ToString());
TextBox1.Text += (myReader["aanvraag_omschrijving"].ToString());
TextBox1.Text += (myReader["doorlooptijd_id"].ToString());
TextBox1.Text += (myReader["rapporteren"].ToString());
TextBox1.Text += (myReader["werknemer_id"].ToString());
TextBox1.Text += (myReader["outlook_id"].ToString());
}
}
好吧,你必须订购一些东西。您有主键吗?也许是ID?
—
2011年
“最后记录”是什么意思?主键列的值最高?
—
Marcin Wroblewski