imagelist在使用前必须初始化?

OptionExplicitDimGconnAsNewADODB.ConnectionDimRsAsADODB.RecordsetDimRsFieldAsADODB.Re... Option Explicit
Dim Gconn As New ADODB.Connection
Dim Rs As ADODB.Recordset
Dim RsField As ADODB.Recordset
Dim MaTable As String
Dim num As Long

Dim BaseConn As String
Dim ChaineConn As String

Private Sub Command1_Click()
Dim Node As Node
Dim etape1 As Node
Dim etape2 As Node
cd.Filter = "Base Access|*.mdb"
cd.ShowOpen
ChaineConn = BaseConn & cd.FileName '
If cd.FileName = "" Then Exit Sub
trv.Nodes.Clear
Gconn.Open ChaineConn

Set Rs = Gconn.OpenSchema(adSchemaTables)
Set Node = trv.Nodes.Add(, , , "<BASE>", 1, 1)
Node.Expanded = True
Do While Not Rs.EOF
Select Case LCase(Rs.Fields(3))
Case "table"
num = 2
Case Is = "view"
num = 5
Case "system table"
num = 6
Case Else
num = 4
End Select
Set etape1 = trv.Nodes.Add(Node, tvwChild, , Rs.Fields(2).Value, num, num)
Set RsField = Gconn.OpenSchema(adSchemaColumns)
Do While Not RsField.EOF
If RsField.Fields(2) = Rs.Fields(2) Then
Set etape2 = trv.Nodes.Add(etape1, tvwChild, , RsField.Fields(3), 3, 3)
End If
RsField.MoveNext
Loop
Rs.MoveNext
Loop
Gconn.Close
End Sub

Private Sub Command2_Click()
Static Flag As Boolean
Flag = Not Flag
If Not Flag Then
Me.Width = 7755
Command2.Caption = "隐藏"
Else
Me.Width = 3975
Command2.Caption = "显示"
End If
End Sub

Private Sub Form_Load()
BaseConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
End Sub

Private Sub trv_NodeClick(ByVal Node As MSComctlLib.Node)
Dim rep As Long
Dim RsPrivate As ADODB.Recordset
Dim item As ListItem
Dim Requete As String
Dim H, G As Integer
Gconn.Open ChiaineConn

MaTable = Replace(Node.FullPath, "<Base>\", "")
rep = InStr(MaTable, "\")
If rep > 0 Then
MaTable = Left$(MaTable, rep - 1)
End If
Requete = "select * from" & MaTable
On Error GoTo hd1
Set RsPrivate = Gconn.Execute(Requete)
lstv.ColumnHeaders.Clear

For H = 0 To RsOrivate.Fields.Count - 1
lstv.ColumnHeaders = Add(, , RsPrivate.Fields(0))
For G = 1 To RsPrivate.Fielsds.Count - 1
item.SubItems(G) = RsPrivate.Fields(G)
Next
RsPrivate.MoveNext
Loop
'sb.Panels(1).Text="OK"
Gconn.Close
Exit Sub
hd1:
On Error Resume Next
Gconn.Close
End Sub

代码如上,就是不知道为啥了,删除imagelist还是那样提示 初始化
DreamMuse:
代码我改了ctrl+F5可以运行了 但是还是有那个错误 下面是代码后半部分那个RsOrivate发现是RsPrivate-.-#:麻烦了谢谢

Private Sub trv_NodeClick(ByVal Node As MSComctlLib.Node)
Dim rep As Long
Dim RsPrivate As ADODB.Recordset
Dim item As ListItem
Dim Requete As String
Dim H, G As Integer
Gconn.Open ChaineConn

MaTable = Replace(Node.FullPath, "<Base>\", "")
rep = InStr(MaTable, "\")
If rep > 0 Then
MaTable = Left$(MaTable, rep - 1)
End If
Requete = "select * from" & MaTable
On Error GoTo hd1
Set RsPrivate = Gconn.Execute(Requete)
lstv.ColumnHeaders.Clear

For H = 0 To RsPrivate.Fields.Count - 1
lstv.ColumnHeaders.Add , , RsPrivate.Fields(H).Name
Next
Do While Not RsPrivate.EOF
Set item = lstv.ColumnHeaders.Add(, , RsPrivate.Fields(0))
For G = 1 To RsPrivate.Fields.Count - 1
item.SubItems(G) = RsPrivate.Fields(G)
Next
RsPrivate.MoveNext
Loop
'sb.Panels(1).Text="OK"
Gconn.Close
Exit Sub

hd1:
On Error Resume Next
Gconn.Close
End Sub
展开
 我来答
DreamMuse
2009-10-16 · TA获得超过989个赞
知道小有建树答主
回答量:344
采纳率:0%
帮助的人:355万
展开全部
那是在哪里出错误?一开始就错,还是按了command1……
这些问题要说清楚,要不很难找症结呀,而且我没有你的数据库文件,如果问题处在数据库那里,那可能还要追究一下系统,我遇过数据库出问题了还得重装系统才能解决(不过本人对数据库非常菜)。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式