简单说, 就是取出几条纪录, 再刷新纪录的值, 我现在的做法是:SQLQuery = "select * from t1 where seq<new_seq"
Results1.Open SQLQuery, MySQLConnectionDo Until Results1.EOF
MySQLConnection.Execute "update t1 set seq=" & Str(Results1!new_seq) & " where id=" & Str(Results1!id)
        Results1.MoveNext
LoopResults1.Close
以上是vb程序, 此外web上也会刷新new_seq的值, 也就是可能web和vb同时对这个表操作现状是: 每次程序运行1天, 就会run-time报错: 说odbc有问题, 或说server shutdown
看了书,好像不应该这么update, 或者是不是同步操作表的问题... 大家帮忙指点一下

解决方案 »

  1.   

    不要循环执行。只用一个 SQL 语句:
    MySQLConnection.Execute "update t1 set seq=new_seq where id IN (SELECT id FROM t1 where seq<new_seq)"
      

  2.   

    恩,不要循环就可以的,再加上事务处理:On Error GoTo err:
    MySQLConnection.BeginTrans
    MySQLConnection.Execute "update t1 set seq=new_seq where id IN (SELECT id FROM t1 where seq<new_seq)"
    MySQLConnection.CommitTrans
    err:
        MsgBox err.Description
        conn.RollbackTrans
      

  3.   

    不用循环 可以优化为:MySQLConnection.Execute "update t1 set seq=new_seq where seq<new_seq)"