VERSION 5.00
Object = "{65E121D4-0C60-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCHRT20.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2460
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9345
   LinkTopic       =   "Form1"
   ScaleHeight     =   2460
   ScaleWidth      =   9345
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "课程平均分"
      Height          =   315
      Left            =   6660
      TabIndex        =   2
      Top             =   2100
      Width           =   1395
   End
   Begin VB.CommandButton Command1 
      Caption         =   "个人平均分"
      Height          =   315
      Left            =   4980
      TabIndex        =   1
      Top             =   2100
      Width           =   1335
   End
   Begin MSChart20Lib.MSChart MSChart1 
      Bindings        =   "sy11-20.frx":0000
      Height          =   2235
      Left            =   -120
      OleObjectBlob   =   "sy11-20.frx":0015
      TabIndex        =   0
      Top             =   -240
      Width           =   9255
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   120
      Top             =   2100
      Width           =   4395
      _ExtentX        =   7752
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    'Group by 确定分组对象，本事件按个人
    'Order by 排序处理
    Dim sql As String, mpath As String
    mpath = App.Path
    If Right(mpath, 1) <> "\" Then mpath = mpath + "\"
    sql = "Select Student.姓名,Avg(成绩) As 平均分,min(成绩) As 最低分, max(成绩) As 最高分"
    sql = sql + " From Class,Student Where Student.学号=Class.学号"
    sql = sql + " Group by 姓名 Order by Avg(成绩);"
    mlink = "Provider=Microsoft.Jet.OLEDB.3.51; Persist Security Info=False;"
    mlink = mlink + "Data Source=" + mpath + "Mydb.mdb"
    Adodc1.ConnectionString = mlink
    Adodc1.CommandType = adCmdUnknown
    Adodc1.RecordSource = sql
    Adodc1.Refresh
End Sub

Private Sub Command2_Click()
    Dim sql As String, mpath As String
    mpath = App.Path
    If Right(mpath, 1) <> "\" Then mpath = mpath + "\"
    sql = "Select 课程名,专业,Avg(成绩) As 平均分"
    sql = sql + " From Class,Student Where Student.学号=Class.学号"
    sql = sql + " Group by 课程名,专业 ;"
    mlink = "Provider=Microsoft.Jet.OLEDB.3.51;"
    mlink = mlink + "Data Source=" + mpath + "Mydb.mdb"
    Adodc1.ConnectionString = mlink
    Adodc1.CommandType = adCmdUnknown
    Adodc1.RecordSource = sql
    Adodc1.Refresh
End Sub


