home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form ADOForm
- Caption = "ADO Example 1"
- ClientHeight = 3336
- ClientLeft = 60
- ClientTop = 348
- ClientWidth = 6588
- LinkTopic = "Form1"
- ScaleHeight = 3336
- ScaleWidth = 6588
- StartUpPosition = 3 'Windows Default
- Begin VB.ListBox List2
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 2640
- Left = 2760
- TabIndex = 1
- Top = 480
- Width = 3615
- End
- Begin VB.ListBox List1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 2640
- Left = 240
- TabIndex = 0
- Top = 480
- Width = 2295
- End
- Begin VB.Label Label2
- Caption = "Selected Products"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 300
- Left = 2784
- TabIndex = 3
- Top = 144
- Width = 2196
- End
- Begin VB.Label Label1
- Caption = "Product Category"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 300
- Left = 288
- TabIndex = 2
- Top = 144
- Width = 2196
- End
- Attribute VB_Name = "ADOForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim ADOConnection As Connection
- Dim RSCategories As Recordset
- Dim RSProducts As Recordset
- Private Sub Form_Load()
- Set ADOConnection = CreateObject("ADODB.Connection")
- Set RSCategories = CreateObject("ADODB.Recordset")
- ConnectionString = "DSN=NWindDB"
- ADOConnection.Open ConnectionString
- RSCategories.Open "SELECT CategoryName, CategoryID FROM Categories", ADOConnection
- Set RSProducts = CreateObject("ADODB.Recordset")
- While Not RSCategories.EOF
- List1.AddItem RSCategories("CategoryName")
- List1.ItemData(List1.NewIndex) = RSCategories("CategoryID")
- RSCategories.MoveNext
- Wend
- End Sub
- Private Sub List1_Click()
- RSProducts.Open "SELECT ProductName FROM Products WHERE CategoryID=" & List1.ItemData(List1.ListIndex), ADOConnection
- List2.Clear
- While Not RSProducts.EOF
- List2.AddItem RSProducts("ProductName")
- RSProducts.MoveNext
- Wend
- RSProducts.Close
- End Sub
-