在多用户使用时,某一条记录不让多用户同时修改。如何做?
sql server 2000
是否使用事务处理呢?如何使用?事务放在哪里?
谢谢
sql server 2000
是否使用事务处理呢?如何使用?事务放在哪里?
谢谢
解决方案 »
- ocx文件,如何在 不注册的情况下动态调用(不用regsvr32 *.ocx)
- [菜鸟问题]很简单的问题,希望指教帮帮小弟(在线等待)
- 请教大家一个问题!
- 帮我做个同步专家这样的软件要多少钱啊! 有诚意的出个价, 制作人要在上海哦
- 小问题:字母按顺序自动产生,如 aa, ab, ac ...
- 十万火急,希望各位老大帮忙。我现在用到文本文件数据库,当在碰到中文时就出现乱码的问题,这是怎么回事呀???
- 我不知道问题出在哪!请高手帮帮忙!小弟感激不尽!!!
- 找工作的问题,顺便散分
- 关于listview多行选择的问题
- 急急急!onTime中执行Application.Terminate,出现内存访问错误。请哪位高手指点一二,谢谢
- 如何显示sql数据库中的数据??
- 图形界面
begin
result:=false;
if DMFreights.Queryfreight.Connection.InTransaction then
DMFreights.Queryfreight.Connection.RollbackTrans;
DMFreights.Queryfreight.Connection.BeginTrans;// /开始事务 try
// Connection.BeginTrans;// /开始事务
if DMFreights.Queryfreight.RecordCount>0 then
begin
with DMFreights.Queryfreight do
begin
if VarIsNull(FieldValues['Payer']) or VarIsEmpty(FieldValues['Payer'])or VarIsNull(FieldValues['Account'])or VarIsEmpty(FieldValues['Account']) or VarIsNull(FieldValues['freight_name'])or VarIsEmpty(FieldValues['freight_name']) or
VarIsNull(FieldValues['Remained'])or VarIsEmpty(FieldValues['Remained']) then
begin
result:=false;
slkDBGrid1.SetFocus;
DMFreights.Queryfreight.Connection.RollbackTrans;
exit;
end
else
begin
if DMFreights.Queryfreight.FieldByName('Account').AsFloat = 0 then
begin
result:=false;
slkDBGrid2.SetFocus;
DMFreights.Queryfreight.Connection.RollbackTrans;
exit;
end
else
begin
UpdateBatch;
Refresh
end;
end;
end;
end
else
begin
with DMFreights.Queryfreight do
begin
UpdateBatch;
refresh;
end;
end; if Panel1.Visible= true then
begin
if DMFreights.Queryfreight1.RecordCount>0 then
begin
with DMFreights.Queryfreight1 do
begin
if VarIsNull(FieldValues['Payer'])or VarIsEmpty(FieldValues['Payer']) or VarIsNull(FieldValues['Account'])or VarIsEmpty(FieldValues['Account']) or VarIsNull(FieldValues['freight_name'])or VarIsEmpty(FieldValues['freight_name']) or
VarIsNull(FieldValues['Remained'])or VarIsEmpty(FieldValues['Remained']) then
begin
result:=false;
slkDBGrid2.SetFocus;
DMFreights.Queryfreight.Connection.RollbackTrans;
exit;
end
else
begin
if DMFreights.Queryfreight1.FieldByName('Account').AsFloat = 0 then
begin
result:=false;
slkDBGrid2.SetFocus;
DMFreights.Queryfreight.Connection.RollbackTrans;
exit;
end
else
begin
UpdateBatch;
Refresh
end;
end;
end;
end
else
begin
with DMFreights.Queryfreight1 do
begin
UpdateBatch;
refresh;
end;
end;
end;
DMFreights.Queryfreight.Connection.CommitTrans;
except
DMFreights.Queryfreight.Connection.RollbackTrans;
exit;
end;
result:=true;
end;
我使用的是ado连接到sql 20000上的。
有的说使用事务处理如下: if (not adoconnection1.intransaction) then
begin
adoconnection1.begintrans;
end ;
try
//你的代码
adoconnection1.committrans;
except
adoconnection1.rollbacktrans;
end;但不知道上面的这些语句是放在哪个控件的哪个属性中?
Sql Server 2000 在更新表时会自动锁表,也就是每个时间单位最多只有一个用户更新表
我发现是第1位修改的数据被系统接受,而其它用户再修改时,虽然不接受,但也没有什么提示,这样总觉得不怎么方便。
作用是当try块中的代码在执行过程中发生错误(也就是异常),则执行except块中的内容,而发生异常后的语句块不在执行,直接执行end后的语句。目的是要增加代码的健壮性和容错性,使程序发生异常时不至于退出。