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 展开
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 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询