Public Function getRS(ByVal sql As String) As ADODB.Recordset '就是这句发生这个什么用户定义类型未定义这个错误.Dim myconn As New ADODB.Connection
Dim rs As New ADODB.Recordsetstrconnection = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=" & "DSN=zjnulibrary;Description=图书馆数据;APP=Visual Basic;WSID=ZJNUV;DATABASE=zjnulibrary;Trusted_Connection=Yes"
On Error GoTo getrs_error rs.open sql, myconn, 3, 3
Set getRS = rs
getrs_exit:
Set rs = Nothing
Set myconn = Nothing
Exit Function
getrs_error:
MsgBox "发生错误:" & Err.Description, vbOKOnly, "错误警告"
Resume getrs_exitEnd FunctionPublic Sub sqlexe(ByVal sql As String)
Dim myconn As New ADODB.Connection
On Error GoTo sqlexe_error
myconn.Execute (sql)
sqlexe_exit:
Set myconn = Nothing
Exit Sub
sqlexe_error:
MsgBox "发生错误:" & Err.Description, vbOKOnly, "错误警告"
Resume sqlexe_exitEnd SubSub main()
Dim newfrm As New MDIForm1
newfrm.Show
End Sub
Dim rs As New ADODB.Recordsetstrconnection = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=" & "DSN=zjnulibrary;Description=图书馆数据;APP=Visual Basic;WSID=ZJNUV;DATABASE=zjnulibrary;Trusted_Connection=Yes"
On Error GoTo getrs_error rs.open sql, myconn, 3, 3
Set getRS = rs
getrs_exit:
Set rs = Nothing
Set myconn = Nothing
Exit Function
getrs_error:
MsgBox "发生错误:" & Err.Description, vbOKOnly, "错误警告"
Resume getrs_exitEnd FunctionPublic Sub sqlexe(ByVal sql As String)
Dim myconn As New ADODB.Connection
On Error GoTo sqlexe_error
myconn.Execute (sql)
sqlexe_exit:
Set myconn = Nothing
Exit Sub
sqlexe_error:
MsgBox "发生错误:" & Err.Description, vbOKOnly, "错误警告"
Resume sqlexe_exitEnd SubSub main()
Dim newfrm As New MDIForm1
newfrm.Show
End Sub
已经加了啊.
我在建立根节点的时候用的是这样的代码
Private Sub Form_Load()
Dim NodX As Node
Do While Data1.Recordset.EOF
Set NodX = TreeView1.Nodes.Add(, , Chr(Data1.Recordset.Fields("编号1").Value), Data1.Recordset.Fields("公司").Value)
NodX.Tag = Data1.Recordset.Fields("编号1")
Data1.Recordset.MoveNext
Loop
End Sub
系统老是报错“错误91,对象变量或with块变量未设置”
我明明把data控件设定好了,数据库也绑定正确,真是奇怪啊!
能不能帮我解决一下问题!