如何取得刚刚插入的数据的自增的id,比如,注册时,我在插入数据的同时并把刚刚插入的数据的id显示到页面上,不用时间差??

解决方案 »

  1.   

    看看这个帖子,
    http://community.csdn.net/Expert/topic/5399/5399727.xml?temp=.5974085
      

  2.   

    我用的是@@identity
    在后台我的代码是
    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
      

  3.   

    存储过程写Add方法,会返回值,就是你添加的ID;sql语句可能办不到;
      

  4.   

    你在设置数据库的时候设置一列自动增加ID的列就行了,绑定数据库的网页只要刷新就有刚刚增加的数据了!比如用response.write(javascript.load("网页名"))