?????怎么实现数据存储时个数自动加一,当数据删除时个数自动减一???请高手指点!!!!
若有源代码请示例:1:数据存储时:
private void Button1_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
string strCommand="insert 新生报名表 values('"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"','"+TextBox4.Text+"','"+TextBox5.Text+"','"+TextBox6.Text+"','"+TextBox7.Text+"','"+TextBox8.Text+"','"+TextBox9.Text+"','"+TextBox10.Text+"',"+TextBox11.Text+","+TextBox12.Text+","+TextBox13.Text+",'"+TextBox14.Text+"','"+TextBox15.Text+"')";
SqlCommand addScore=new SqlCommand(strCommand,myConnection);
myConnection.Open();
addScore.ExecuteNonQuery();
myConnection.Close();
BindGrid("新生报名表");
//Server.Transfer("车辆信息窗口1.aspx");
Label1.Text="新生信息插入成功!";
TextBox1.Text="";
TextBox2.Text="";
TextBox3.Text="";
TextBox4.Text="";
TextBox5.Text="";
TextBox6.Text="";
TextBox7.Text="";
TextBox8.Text="";
TextBox9.Text="";
TextBox10.Text="";
TextBox11.Text="";
TextBox12.Text="";
TextBox13.Text="";
                TextBox14.Text="";
TextBox15.Text=""; }
else
{
Response.Write("<script lanuage='javascript'>alert('对不起,你所输入的列表项中有误,请您仔细核对后再重新输入!')</script>");
} }
}
}

解决方案 »

  1.   

    select count(*) from 新生报名表?还是什么?不明白你的意思。
      

  2.   

    select count(*) as RowCount from YourTableName
      

  3.   

    本人在TABLE中要设定一个字段为序号,实现每加一条记录序号自动加1,如果删除其中某一条记录就相应序号自动减1。请问如何实现,并请列出详细方法?
      

  4.   

    再加一个计数的表,自己写语句了update
      

  5.   

    在insert语句后紧跟一条select 语句:select count(*)
    这样就不用计算有多少条数据了.
      

  6.   

    http://218.27.204.17/aspnet/a_user.aspx
      

  7.   

    加一:@id=select count(*) from table
              @id=id+1
    insert into table(id) values(@id)
    减一
    delete from table where id=@id
    --删除时减一操作,大于这条记录的所有id都要自动减一才能保证你的程序正确运行,因此使用游标
            declare au_cursor cursor for
    select id from table order by id
    open au_cursor
    fetch next from au_cursor into @id 
    while(@@fetch_status=0)
    begin
    update table set id=id-1
    end
    close au_cursor
    deallocate au_cursor以上代码未存储过程中的代码
      

  8.   

    oracle:  用序列,每调用一回.nextval,seq自动增加1
    例:
    select seq.nextval from dual
    seq为你创建的序列
      

  9.   

    这种功能用存储过程来实现:create procedure XXXXX on tableName 
    for after insert, update
    as
    ......不同数据库有不同写法,我也记不清了。