VB6.0提示用户定义类型未定义第一句错了不知道怎么改
PublicFunctionExecuteSQL(ByValSQLAsString,MsgStringAsString)AsADODB.RecordsetDimcnnAs...
Public Function ExecuteSQL(ByVal SQL As String, MsgString As String) As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sTokens() As String
On Error GoTo ExecuteSQL_Error
sTokens = Split(SQL)
Set cnn = New ADODB.Connection
cnn.Open ConnectString
If InStr("INSERT,DELETE,UPDATE,EXECUTE", UCase$(sTokens(0))) Then
cnn.Execute (SQL)
MsgString = sTokens(0) & "查询成功"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
Set ExecuteSQL = rst
MsgString = "查询到" & rst.RecordCount & "条记录"
End If
ExecuteSQL_Exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
ExecuteSQL_Error:
MsgString = "查询错误"
Resume ExecuteSQL_Exit
End Function
我选了但是又出现实时错误‘438’对象不支持该属性或方法
Private Sub MDIForm_Load()
StatusBar1(0).Panels(2).Text = "当前用户:" & Trim(UserName)
StatusBar1(0).Panels(3).Text = Format(Now, "yyyy" & "年" & "M" & "月" & "d" & "日")
StatusBar1(0).Panels(4).Text = Format(Now, "H:mm:ss")
End Sub
这段的第2句 展开
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sTokens() As String
On Error GoTo ExecuteSQL_Error
sTokens = Split(SQL)
Set cnn = New ADODB.Connection
cnn.Open ConnectString
If InStr("INSERT,DELETE,UPDATE,EXECUTE", UCase$(sTokens(0))) Then
cnn.Execute (SQL)
MsgString = sTokens(0) & "查询成功"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
Set ExecuteSQL = rst
MsgString = "查询到" & rst.RecordCount & "条记录"
End If
ExecuteSQL_Exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
ExecuteSQL_Error:
MsgString = "查询错误"
Resume ExecuteSQL_Exit
End Function
我选了但是又出现实时错误‘438’对象不支持该属性或方法
Private Sub MDIForm_Load()
StatusBar1(0).Panels(2).Text = "当前用户:" & Trim(UserName)
StatusBar1(0).Panels(3).Text = Format(Now, "yyyy" & "年" & "M" & "月" & "d" & "日")
StatusBar1(0).Panels(4).Text = Format(Now, "H:mm:ss")
End Sub
这段的第2句 展开
1个回答
展开全部
没有引用 Microsoft ActiveX Data Objects 2.0 LIbrary造成的
菜单“工程”-“引用”
PS:实时错误‘438’在哪一句?
ps:这个程序是哪里拷贝的?StatusBar1(0)是状态栏控件数组,你添加了该控件么?
菜单“工程”-“部件” Microsoft
windows commom controls 6.0
注意是 控件 数组
另外Panels(4)也是要通过StatusBar1(0).Panels.Add增加Panels的数量,否则会下标越界
晕倒……
菜单“工程”-“引用”
PS:实时错误‘438’在哪一句?
ps:这个程序是哪里拷贝的?StatusBar1(0)是状态栏控件数组,你添加了该控件么?
菜单“工程”-“部件” Microsoft
windows commom controls 6.0
注意是 控件 数组
另外Panels(4)也是要通过StatusBar1(0).Panels.Add增加Panels的数量,否则会下标越界
晕倒……
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询