📄 frmmain.frm
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmMain
Caption = "Stored Procedure"
ClientHeight = 7515
ClientLeft = 60
ClientTop = 345
ClientWidth = 6570
LinkTopic = "Form1"
ScaleHeight = 7515
ScaleWidth = 6570
StartUpPosition = 3 'Windows Default
Begin VB.OptionButton optAuthorTitle
Caption = "Author Title"
Height = 375
Left = 1800
TabIndex = 2
Top = 240
Width = 1455
End
Begin VB.OptionButton optTitleAuthor
Caption = "Title Author"
Height = 375
Left = 240
TabIndex = 1
Top = 240
Value = -1 'True
Width = 1335
End
Begin ComctlLib.TreeView treeResults
Height = 6495
Left = 120
TabIndex = 0
Top = 840
Width = 6255
_ExtentX = 11033
_ExtentY = 11456
_Version = 393217
Style = 7
Appearance = 1
_Nodes = "frmMain.frx":0000
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private mConn As Connection
Private Sub Form_Load()
'open the connection
Set mConn = New Connection
mConn.Open "Provider=SQLOLEDB.1;User ID=sa;Password=password;" _
+ "Location=WINEMILLER;Database=pubs"
RefreshList
End Sub
Private Sub Form_Unload(Cancel As Integer)
mConn.Close
Set mConn = Nothing
End Sub
Private Sub RefreshList()
Dim rs As Recordset
Dim NewNode As Node
treeResults.Nodes.Clear
If optTitleAuthor.Value = True Then
'sort by titles
Dim sLastTitle As String
'use the Execute method to generate the Recordset
'works the same as adOpenForwardOnly, adLockReadOnly
Set rs = mConn.Execute("GetTitleAuthorList", , adCmdStoredProc)
Do Until rs.EOF
If sLastTitle <> rs("title") Then
'need a new parent
sLastTitle = rs("title")
Set NewNode = treeResults.Nodes.Add(, , rs("title") _
, rs("title"))
NewNode.Expanded = True
End If
'add the child
treeResults.Nodes.Add sLastTitle, tvwChild _
, sLastTitle + rs("au_lname") & ", " & rs("au_fname") _
, rs("au_lname") & ", " & rs("au_fname")
rs.MoveNext
Loop
Else
'sort by authors
Dim sLastAuthor As String
Set rs = New Recordset
rs.Open "GetAuthorTitleList", mConn, adOpenForwardOnly _
, adLockReadOnly, adCmdStoredProc
Do Until rs.EOF
If sLastAuthor <> rs("au_lname") & ", " & rs("au_fname") Then
'need a new parent
sLastAuthor = rs("au_lname") & ", " & rs("au_fname")
Set NewNode = treeResults.Nodes.Add(, , sLastAuthor _
, sLastAuthor)
NewNode.Expanded = True
End If
'add the child
treeResults.Nodes.Add sLastAuthor, tvwChild, sLastAuthor _
+ rs("title"), rs("title")
rs.MoveNext
Loop
End If
End Sub
Private Sub optAuthorTitle_Click()
RefreshList
End Sub
Private Sub optTitleAuthor_Click()
RefreshList
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -