insert into tb(...) values (...) select @@identity
但是属于selectcommad  还是 insertcommand
有人试验过吗?

解决方案 »

  1.   

    insert into tb(...) values (...) ; select @@identity用reader接收 select @@identity 的值
      

  2.   

    sql可以一次执行多条语句,可以用来返回select @@identity
      

  3.   

    属于 SelectCommand 吧,没试过
    我的理解是它有返回值就可以作为 SelectCommand
      

  4.   

    我现在是在asp.net中用 
    不知道cmd.selectcommand = sqlstr 还是 cmd.insertcommand=sqlstr;
    还是不能这样用
    楼上说用reader
    我试试看~~
      

  5.   


    我还以为你要在 SqlDataSource 中使用你这个需求,可以把那句 SQL 赋值给 SqlCommand 对象的 CommandText 属性,然后使用 cmd.ExecuteScalar() 方法获得返回值也可以向上面那位说的那样,用 reader 读出返回值
      

  6.   

     弄错了~  sqlcommand只有commandtext 没有 selectcommand 和insertcommandselectcommand 和 insertcommand是sqldataadapter的