日期:2014-05-19  浏览次数:20451 次

我的后台代码应该改成什么样的啊??
我存储过程中用的是@@identity想得到刚刚插入数据的id
在后台我的代码是
SqlParameter   id   =   new   SqlParameter( "@id ",SqlDbType.Int);

id.Direction   =   ParameterDirection   .Output;
comm   .Parameters   .Add(id);

conn.Open();
comm   .ExecuteNonQuery();
conn.Close();
Object   Outputid   =   comm.Parameters[ "@id "].Value.ToString();

this.Txtid   .Text   =   id.ToString();

但页面显示的结果是@@identity
请各位指点我怎么显示id啊!

------解决方案--------------------
你的存储是如何写的,有这样set @id = @@identity么?
------解决方案--------------------
create procedure procname
(
@outputid int output,
@paraname1 type,
@paraname2 type
)
as
insert into tablename(section1,section2) values()
select
@output=@@identity
go