当前位置: 代码迷 >> ASP.NET >> select top 一 id from title order by id desc
  详细解决方案

select top 一 id from title order by id desc

热度:9009   发布时间:2013-02-25 00:00:00.0
select top 1 id from title order by id desc
C#中如何将上面select top 1 id from title order by id desc这句的ID值传给一个变量,如TID

------解决方案--------------------------------------------------------
select top 1 id as TId from title order by id desc
------解决方案--------------------------------------------------------
变量是存储过程中的如:

declare @tid int 
select top 1 @tid =id from title order by id desc 


变量是C#程序中的:


sqlconnection conn=new sqlconnection(连接字符串);
sqlcommand cmd=new sqlcommand("select top 1 id from title order by id desc",conn);
int tid=convert.ToInt32(cmd.ExecuteScalar());



  相关解决方案