在数据库中插入记录,并返回自动递增字段值. [英] Insert record in data base and return auto increment field value.
本文介绍了在数据库中插入记录,并返回自动递增字段值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我有数据库临时文件.
ID(自动递增)int
名称varchar(50)
密码varchar(50)
我使用Procedure插入一条记录,然后我想插入由sqlserver自动递增的记录id.我如何在项目中完成以上任务.
如果您有与此相关的任何程序,请帮助我.
谢谢
Hiren Bhalsod
Hi friends ,
I have database temp.
Id (autoincrement) int
name varchar(50)
password varchar(50)
i insert one record using Procedure , then i want to fech that inserted record id which is autoincrement by sqlserver. How i can done above thing in project.
if you have any program related to this then plz help me.
Thanx
Hiren Bhalsod
推荐答案
阅读此 @@ IDENTITY (Transact-SQL) [^ ].
想象一下...如果您像我一样用Google搜索过,就不必等待答案了.
下一行将告诉您输入到指定表中的最后一个身份.
Imagine... If you had googled this (like I did), you wouldn''t have had to wait for an answer...
The following line will tell you the last identity that was entered into the specified table.
SELECT IDENT_CURRENT(‘tablename’)
thanx来提供帮助,我在过程中使用了它并且可以正常工作,但是问题是我的.aspx页面中如何获取此值.
=============
来自JSOP:您可以返回它(就像在C#中返回值一样),也可以为存储过程设置输出参数. Google是您的朋友.
thanx for the help , i used in procedure and it work but problem is in my .aspx page how i can get this value.
==============
From JSOP: You can either return it (like you return a value in C#), or set an output parameter for your stored procedure. Google is your friend.
这篇关于在数据库中插入记录,并返回自动递增字段值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文