如何在C#的文本框中从sql获取最后一条记录 [英] How to get the last record from sql in a text box in C#

查看:163
本文介绍了如何在C#的文本框中从sql获取最后一条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,大家晚上好.
我想在窗体加载事件的文本框中从sql表中检索最后一条记录.能否请您帮我,并告诉我有关该程序的完整代码,所以我无法从表中获取最后一条记录.每个领带都应该是最后的记录....






在此先感谢您

Dear All Friends Very Good evening.
I want to retrive the last record from a sql table in a text box on the form load event. can your please help me and tell me the full code for that, so i cant get the last record from a table . every tiem it should be last record ....






thanks in advance

推荐答案

在不了解您的系统的情况下,我们无法真正告诉您.从技术上讲,除非您在发出SELECT命令时指定特定顺序,否则SLQ可以按其选择的任何顺序返回记录.也就是说,通常无法保证先返回记录到数据库中的顺序是先返回的,例如,在压缩数据库的情况下,可以随时更改记录.

您在记录上打上时间或日期戳吗?还是使用顺序ID号?如果是这样,那么这只是
的一种情况
We can''t really tell you, without knowing more about your system. Technically, SLQ can return records in any order it chooses, unless you specify a specific order when you issue the SELECT command. That is generally returns records in the order of first into the database is returned first is not guaranteed and may be changed at any time if the DB is compacted for example.

Do you time or date stamp your records? Or use a sequential ID number? If so, then it is just a case of
SELECT * FROM myTable WHERE myColumn=MAX(myColumn)

或类似的结果.


表上是否有ID.您可以选择按ID降序排列的行,然后将返回的行限制为1.
Do you have an id on the table. You could select the rows ordering by the id in descending order and then limit the rows returned to 1.


这篇关于如何在C#的文本框中从sql获取最后一条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆