home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
- Begin VB.Form ADO2Form
- Caption = "ADO Examples"
- ClientHeight = 5628
- ClientLeft = 60
- ClientTop = 348
- ClientWidth = 8004
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- ScaleHeight = 5628
- ScaleWidth = 8004
- StartUpPosition = 3 'Windows Default
- Begin MSFlexGridLib.MSFlexGrid Grid1
- Height = 2772
- Left = 2604
- TabIndex = 3
- Top = 2748
- Width = 5268
- _ExtentX = 9292
- _ExtentY = 4890
- _Version = 393216
- Rows = 20
- Cols = 4
- FixedCols = 0
- AllowUserResizing= 1
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- End
- Begin VB.CommandButton Command2
- Caption = "Command.Execute"
- Height = 495
- Left = 84
- TabIndex = 2
- Top = 2748
- Width = 2295
- End
- Begin VB.ListBox List1
- Height = 2208
- Left = 2604
- TabIndex = 1
- Top = 108
- Width = 3228
- End
- Begin VB.CommandButton Command1
- Caption = "Connection.Execute"
- Height = 495
- Left = 84
- TabIndex = 0
- Top = 108
- Width = 2295
- End
- Attribute VB_Name = "ADO2Form"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub Command1_Click()
- Dim ADOconnection As New ADODB.Connection
- Dim RSSales As ADODB.Recordset
- Set ADOconnection = CreateObject("ADODB.Connection")
- ADOconnection.Open "DSN=NWindDB" ' "driver ={Microsoft Access Driver (*.mdb)};dbq=c:\data\intranet\intranet.mdb"
- Set RSSales = ADOconnection.Execute("SELECT * FROM CATEGORIES")
- While Not RSSales.EOF
- List1.AddItem RSSales("CategoryName")
- RSSales.MoveNext
- End Sub
- Private Sub Command2_Click()
- Dim ADOcommand As New ADODB.Command
- Dim ADOconnection As New ADODB.Connection
- Dim RSSales As New ADODB.Recordset
- Set ADOconnection = CreateObject("ADODB.Connection")
- ADOconnection.Open "DSN=NWindDB"
- Set ADOcommand.ActiveConnection = ADOconnection
- ADOcommand.Prepared = False
- ADOcommand.CommandText = "Invoices"
- ADOcommand.CommandType = adCmdStoredProc
- Set RSSales = ADOcommand.Execute()
- Grid1.Clear
- Grid1.ColAlignment(2) = 6
- Grid1.ColWidth(0) = TextWidth("9,999")
- Grid1.ColWidth(1) = TextWidth("A long customer's name")
- Grid1.ColWidth(2) = TextWidth("$999,999.99")
- Grid1.ColWidth(3) = TextWidth("#99/99/99#")
- Grid1.Row = 0
- Grid1.Col = 0
- Grid1.Text = "##"
- Grid1.Col = 1
- Grid1.Text = "Customer"
- Grid1.Col = 2
- Grid1.Text = "Inv. Total"
- Grid1.Col = 3
- Grid1.Text = "Date"
- Grid1.Row = 1
- invCounter = 1
- custTotal = 0
- Screen.MousePointer = vbHourglass
- While Not RSSales.EOF
- invTotal = Format(RSSales("ExtendedPrice"), "$#,###.00")
- custTotal = custTotal + invTotal
- Grid1.Col = 0
- Grid1.Text = Format(invCounter, "###")
- invCounter = invCounter + 1
- Grid1.Col = 1
- Grid1.Text = RSSales(7)
- thisCustomer = RSSales(7)
- Grid1.Col = 2
- Grid1.Text = invTotal
- Grid1.Col = 3
- Grid1.Text = RSSales(15)
- If Grid1.Row = Grid1.Rows - 1 Then
- Grid1.Rows = Grid1.Rows + 100
- End If
- Grid1.Row = Grid1.Row + 1
- RSSales.MoveNext
- If Not RSSales.EOF Then
- If RSSales(7) <> thisCustomer Then
- Grid1.Col = 1
- Grid1.Text = "TOTAL"
- Grid1.CellFontBold = True
- Grid1.Col = 2
- Grid1.Text = Format(custTotal, "$#,###.00")
- Grid1.CellFontBold = True
- custTotal = 0
- If Grid1.Row = Grid1.Rows - 1 Then
- Grid1.Rows = Grid1.Rows + 100
- End If
- Grid1.Row = Grid1.Row + 1
- End If
- End If
- Screen.MousePointer = vbDefault
- End Sub
-