从表中打印datagrid的最后一行? [英] print last row in datagrid from table?

查看:61
本文介绍了从表中打印datagrid的最后一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要以数据网格形式打印表的最后一行.我正在使用sql server和c#.net ..我要打印表的最近插入的行..您能告诉我答案吗..



i need to print the last row of the table in the data grid form .i am using the sql server and c#.net.. i want to print the recently inserted row of the table.. can u tell me the answer..

推荐答案

如果您的插入语句在代码中,则可以在插入语句之后使用; SELECT SCOPE_IDENTITY,这将返回您插入的最后一个标识值. />
非常简单,可以从中运行另一个select语句以打印出最后一条记录.

http://msdn.microsoft.com/zh-CN /library/ms190315.aspx [ ^ ]

if your insert statement is in your code, you can use ;SELECT SCOPE_IDENTITY after your insert statement, this will return the last identity value that you inserted..

simple enough to run another select statement from this to print out the last record.

http://msdn.microsoft.com/en-us/library/ms190315.aspx[^]

string sqlInsertActivity = "INSERT INTO activity (CodeID, Subject, ActivityPriorityID, CreatedByEmployeeID, AssignmentTaskStatusID) "
	+ "VALUES('82', 'New Document', '2', '" + createdBy + "', '2') "
	+ ";SELECT SCOPE_IDENTITY();";

string activityID = SqlHelper.ExecuteScalar(conn, CommandType.Text, sqlInsertActivity).ToString();



以上是我做过的一个快速示例,该示例将一行插入表中并返回刚刚插入的记录的ID



a quick example above of one I did which inserts a row into a table and returns the id of the record just inserted


这篇关于从表中打印datagrid的最后一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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