主题:[讨论]请朋友们快帮帮忙啊……实时错误3709
实时错误3709 连接无法用于此操作 上下文中它可能关闭或无效
Option Explicit
Dim i As Integer
Dim adors As New ADODB.Recordset
Dim Cn As New ADODB.Connection
Private Sub Command1_Click()
For i = Val(Text1.Text) To Val(Text2.Text)
=====>> adors.Open "select * from tab_xqinfo where 小区编号='" + Trim(Str(i)) + "'", Cn, adOpenKeyset, adLockOptimistic
With adors
If .RecordCount = 0 Then
Set adors = Cn.Execute("insert into tab_xqinfo (小区编号) values('" & Trim(Str(i)) & "')")
Else
MsgBox i & "小区已存在!"
adors.Close
End If
End With
Next i
End Sub[em11][em11][em11][em10]
Option Explicit
Dim i As Integer
Dim adors As New ADODB.Recordset
Dim Cn As New ADODB.Connection
Private Sub Command1_Click()
For i = Val(Text1.Text) To Val(Text2.Text)
=====>> adors.Open "select * from tab_xqinfo where 小区编号='" + Trim(Str(i)) + "'", Cn, adOpenKeyset, adLockOptimistic
With adors
If .RecordCount = 0 Then
Set adors = Cn.Execute("insert into tab_xqinfo (小区编号) values('" & Trim(Str(i)) & "')")
Else
MsgBox i & "小区已存在!"
adors.Close
End If
End With
Next i
End Sub[em11][em11][em11][em10]