如果是sqlserver 数据库,回用到里面事务 类似下面begin tran begin try insert into 我的数据库.dbo.B() select * from A where A.Record_ID = (select Record_ID from inserted) update tb set A=’XX’ where ID=’1’ commit end try begin catch rollback end catch
安要求指点编号订票比如这里是5,如果谁抢先输入对了就得到了订票,否则票已订空 private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (Char)Keys.Return) //如果按下回车键 { if (textBox1.Text.Length > 5) //如果位数大于5 { textBox1.Text = textBox1.Text.Substring(0, 5); //获取前5位数 }//CodeGo.net/ else { int j = 5 - textBox1.Text.Length; //确定增加的位数 for (int i = 0; i < j; i++) { textBox1.Text = "0" + textBox1.Text; } } } }
类似下面begin tran
begin try
insert into 我的数据库.dbo.B()
select *
from A where A.Record_ID = (select Record_ID from inserted)
update tb set A=’XX’ where ID=’1’
commit
end try
begin catch
rollback
end catch
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (Char)Keys.Return) //如果按下回车键
{
if (textBox1.Text.Length > 5) //如果位数大于5
{
textBox1.Text = textBox1.Text.Substring(0, 5); //获取前5位数
}//CodeGo.net/
else
{
int j = 5 - textBox1.Text.Length; //确定增加的位数
for (int i = 0; i < j; i++)
{
textBox1.Text = "0" + textBox1.Text;
}
}
}
}