VB6 执行UPDATE操作是否会锁表
如题
我代码调试的时候
在执行UPDATE操作时 SELECT不了数据一直处于等待状态
直到退出函数
Public Function ExecuteSynEx(ByVal strConn As String, _ ByVal strTableName As String, _ ByVal bIsIdentity As Long, _ ByVal strAddSQL As Variant, _ ByVal strUpdSQL As Variant, _ ByVal strDelSQL As Variant, _ ByRef ReturnMsg As String) As Boolean10 On Error GoTo HError Dim cn As ADODB.Connection Dim lInterID As Long, lTransType As Long Dim i As Long Dim strSQL As String Dim obj As Object Dim lSQLCount As Long '20 GetObjectContext.SetAbort30 ExecuteSynEx = False 40 Set cn = New ADODB.Connection50 cn.Open strConn60 cn.CursorLocation = adUseClient70 cn.CommandTimeout = 3600'80 cn.Execute "alter table " & strTableName & " nocheck constraint all" If bIsIdentity = 1 Then cn.Execute "SET IDENTITY_INSERT " & strTableName & " on" End If90 Set obj = CreateObject("KFOX.StringBuilder")100 lSQLCount = 0110 For i = LBound(strDelSQL) To UBound(strDelSQL)120 strSQL = Trim(strDelSQL(i))130 If Len(strSQL) > 0 Then140 lSQLCount = lSQLCount + 1150 obj.Append strSQL160 End If170 If lSQLCount = 100 Then180 cn.Execute obj.StringValue190 obj.Remove 1, obj.length200 lSQLCount = 0210 If cn.Errors.Count > 0 Then220 Err.Raise -1, "ExecuteSynEx", cn.Errors.Item(0).Description230 End If240 End If250 Next i260 If lSQLCount > 0 Then270 cn.Execute obj.StringValue280 obj.Remove 1, obj.length290 lSQLCount = 0300 If cn.Errors.Count > 0 Then310 Err.Raise -1, "ExecuteSynEx", cn.Errors.Item(0).Description320 End If330 End If340 Set obj = Nothing 350 Set obj = CreateObject("KFOX.StringBuilder")360 lSQLCount = 0370 For i = LBound(strAddSQL) To UBound(strAddSQL)380 strSQL = Trim(strAddSQL(i))390 If Len(strSQL) > 0 Then400 lSQLCount = lSQLCount + 1410 obj.Append strSQL420 End If430 If lSQLCount = 100 Then440 cn.Execute obj.StringValue450 obj.Remove 1, obj.length460 lSQLCount = 0470 If cn.Errors.Count > 0 Then480 Err.Raise -1, "ExecuteSynEx", cn.Errors.Item(0).Description490 End If500 End If510 Next i520 If lSQLCount > 0 Then530 cn.Execute obj.StringValue540 obj.Remove 1, obj.length550 lSQLCount = 0560 If cn.Errors.Count > 0 Then570 Err.Raise -1, "ExecuteSynEx", cn.Errors.Item(0).Description580 End If590 End If600 Set obj = Nothing610 Set obj = CreateObject("KFOX.StringBuilder")620 lSQLCount = 0630 For i = LBound(strUpdSQL) To UBound(strUpdSQL)640 strSQL = Trim(strUpdSQL(i))650 If Len(strSQL) > 0 Then660 lSQLCount = lSQLCount + 1670 obj.Append strSQL680 End If690 If lSQLCount = 100 Then700 cn.Execute obj.StringValue710 obj.Remove 1, obj.length720 lSQLCount = 0730 If cn.Errors.Count > 0 Then740 Err.Raise -1, "ExecuteSynEx", cn.Errors.Item(0).Description750 End If760 End If770 Next i780 If lSQLCount > 0 Then790 cn.Execute obj.StringValue800 obj.Remove 1, obj.length810 lSQLCount = 0820 If cn.Errors.Count > 0 Then830 Err.Raise -1, "ExecuteSynEx", cn.Errors.Item(0).Description840 End If850 End If860 Set obj = Nothing If bIsIdentity = 1 Then cn.Execute "SET IDENTITY_INSERT " & strTableName & " off" End If'870 cn.Execute "alter table " & strTableName & " check constraint all"'880 GetObjectContext.SetComplete890 ExecuteSynEx = True900 Exit FunctionHError:'910 cn.Execute "alter table " & strTableName & " check constraint all" If bIsIdentity = 1 Then cn.Execute "SET IDENTITY_INSERT " & strTableName & " off" End If920 GetObjectContext.SetAbort930 ExecuteSynEx = False940 Err.Raise -1, "ExecuteSynEx", Err.Description & "Erl:" & ErlEnd Function