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());