那是因为在插入数据的时候
DBMS系统使用了锁的机制
这与插入什么的数据无关

解决方案 »

  1.   

    我的代码是根据客户端传入的Clientdataset表的内容确定insert into 语句,代码如下:          sPValue := 'insert into ' + strParm + '( ';
              sValue := ') Values( ';
              For iLoop :=0 To iCount Do
              Begin
                If (Cltds.Fields[iLoop].DataType <> ftAutoInc) And (Not Cltds.Fields[iLoop].IsNull) Then
                Begin
                  sPValue := sPValue + Trim(Cltds.Fields[iLoop].FieldName);
                  sValue := sValue + ' :@1' + Trim(Cltds.Fields[iLoop].FieldName);
                  if iLoop < iCount then
                  Begin
                    sPValue := sPValue+',';
                    sValue := sValue + ',';
                  End;
                End;
              End;
         //需要检查最后是否为' , ', 有则需要除掉
              if Trim(sPValue[Length(sPValue)]) = ',' then
                 sPValue := Copy(sPValue,0,Length(sPValue)-1);
              if Trim(sValue[Length(sValue)]) = ',' then
                 sValue := Copy(sValue,0,Length(sValue)-1);
              sPValue := sPValue + sValue + ' )';
              Query.SQL.Text := sPValue;
              For iLoop :=0 To iCount Do
              Begin
                If (Cltds.Fields[iLoop].DataType <> ftAutoInc) And (Not Cltds.Fields[iLoop].IsNull) Then
                Begin
                  Query.Parameters.ParamByName('@1'+Trim(Cltds.Fields[iLoop].FieldName)).Value := Cltds.Fields[iLoop].Value;
                End;
              End;
            End;
        Try
          Query.ExecSQL;
             // 以上语句如果有多个客户端同时执行的话,出现死锁提示,如何解决
        Except
          Result := False;
        End;
      

  2.   

    delphi
    你插入的时候  其他语句有排他锁
      

  3.   

    Clientdataset中有Clustered Index吗?
      

  4.   

    Please use begin tran or autocommit =  false
      

  5.   

    如果使用事务,最好在每次提交时,都及时commit。
    否则可能会出问题。
      

  6.   


    谢谢,我在try
             except
             end         之后执行了 setcomplete, 因为在com事务中,所以没有显式的 begin tran