获取最后插入的ID [英] get last inserted id

查看:82
本文介绍了获取最后插入的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要在我的表中获取最后一个密码id。怎么做。请帮助

hi all,

i need to get the last inseted id in my table. how to do it. pls help

推荐答案

写入查询
select top 1 id from table_name order by id desc


嗨...

i不能完成....

hi ...
i cant not done ....
con.Open();
            str = "select Num from Pic";
            com = new OleDbCommand(str, con);
            OleDbDataReader reader = com.ExecuteReader();
            reader.Read();
            label1.Text = reader["Num"].ToString() + "  Num";



此show num 1 .. 。

怎么改变得到最后一个数....

请帮帮忙!


this show num 1 ...
how change to get last num ....
please help !


你已经得到了问题的答案但是以下链接将有助于您将来了解如何获得最后插入的ID。



之间有什么区别[ ^ ]
You have already got answer of your problem but following link would be helpful for you in future to get clear idea about how can get last inserted id.

Interview Question: What are the Differences between @@IDENTITY, SCOPE_IDENTITY() and IDENT_CURRENT()[^]


这篇关于获取最后插入的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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