以下代码运行到If Not l_adorsClose.EOF Then就会报对象变量或 With 块变量未设置的错 百度以后将 Dim l_adorsClose As ADODB.Recordset 改为 Dim l_adorsClose As New ADODB.Recordset后又报3701,对象关闭时,不允许操作
求各位大佬帮忙Dim l_sqlClose As String
Dim l_adorsClose As ADODB.Recordset
l_sqlClose = "select cld01 close_date,cld02 close_time,cld05 open_date from cld_file where cld03='Y'" 'B2B关帐时间表
Set l_adorsClose = exesql("B2B", l_sqlClose)
If Not l_adorsClose.EOF Then
l_CloseDate = l_adorsClose("close_date")
l_CloseTime = l_adorsClose("close_time")
l_OpenDate = l_adorsClose("open_date")
End If
l_CurrentDate = Format(Now(), "YYYYMMDD")
l_CurrentTime = Format(Now(), "HHMMSS")
'如果当前日期在关帐日期后,开帐日期前,就退出程式(关帐期间不运行)
If (l_CurrentDate = l_CloseDate And l_CurrentTime >= l_CloseTime) Or (l_CurrentDate > l_CloseDate And l_CurrentDate < l_OpenDate) Then
Exit Sub
End If
求各位大佬帮忙Dim l_sqlClose As String
Dim l_adorsClose As ADODB.Recordset
l_sqlClose = "select cld01 close_date,cld02 close_time,cld05 open_date from cld_file where cld03='Y'" 'B2B关帐时间表
Set l_adorsClose = exesql("B2B", l_sqlClose)
If Not l_adorsClose.EOF Then
l_CloseDate = l_adorsClose("close_date")
l_CloseTime = l_adorsClose("close_time")
l_OpenDate = l_adorsClose("open_date")
End If
l_CurrentDate = Format(Now(), "YYYYMMDD")
l_CurrentTime = Format(Now(), "HHMMSS")
'如果当前日期在关帐日期后,开帐日期前,就退出程式(关帐期间不运行)
If (l_CurrentDate = l_CloseDate And l_CurrentTime >= l_CloseTime) Or (l_CurrentDate > l_CloseDate And l_CurrentDate < l_OpenDate) Then
Exit Sub
End If
解决方案 »
- 急!!已获取网页源码到string变量,再提取其中超链接的问题。
- VB6.0异常,求救!!!
- 求 vb datareport详细编程技术资料!
- sqlserver触发器delete的代码的写法
- 请各位帮忙,删除 msflexgrid 的某列
- 将*.txt文件导入SQL2000的数据库里
- T*.DB
- 返回控件句柄
- 怎么用VB做 RM 播放程序?
- 检测注册表中存在\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC的程序该怎么写?
- VB TIMER控件
- 分享一个Pr Ps Ae C4d Lr插件一键安装的,本人原创的 2019年9月28日发布的,有著作权的哈 ,大家可以免费来领取一份哈
Public Function exesql(SYSID As String, ByVal sSQL As String) As ADODB.Recordset '传递参数系统别,便于数据库连接:
'MES表示MES数据库连接字串;
'SAP表示SAP数据库连接字串;
'B2B表示B2B数据库连接字串;
'自身并以Reconderset对象的形式返回,便于数据库操作。
Dim cnn1 As New ADODB.Connection
Dim adors1 As New ADODB.Recordset
Dim arry() As String '异常处理
On Error GoTo exesql_err
'用Split 函数产生各个字串的数组
arry = Split(Trim$(sSQL))
'打开数据库连接 By 不同的系统类别
Select Case UCase$(Trim$(SYSID))
Case "B2B"
cnn1.Open g_b2b
Case "SAP"
cnn1.Open g_sap
Case "MES"
cnn1.Open g_mes
Case "B2BDS1"
cnn1.Open g_b2bds1
End Select
'判断SQL执行语句到底属于那种操作
If InStr("INSERT,DELETE,UPDATE", UCase$(arry(0))) Then
cnn1.Execute sSQL
Else
With adors1
.CursorLocation = adUseClientBatch
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open sSQL, cnn1
' Set .ActiveConnection = Nothing
End With
Set exesql = adors1
End If
exesql_exit:
Set adors1 = Nothing
'cnn1.Close
Set cnn1 = Nothing
Exit Function
exesql_err:
Resume exesql_exit
' MsgBox Err.Description
End Function
Set adors1 = Nothing
'cnn1.Close
Set cnn1 = Nothing改成
exesql_exit:
'Set adors1 = Nothing
'cnn1.Close
'Set cnn1 = Nothing试试