SQL 数据库课程设计学生成绩系统
Dim s1 As String, s2 As String Set DataGrid1.DataSource = Nothing Combo2.Clear If opt = 0 Then
s1 = "select 课程名称 from 班级课程表 where 班级名称='" s2 = Combo1.Text & "' group by 课程名称" Adodc2.RecordSource = s1 & s2 Else
s1 = "select 学号 from 学生基本信息表 where 班级名称='" s2 = Combo1.Text & "'"
Adodc2.RecordSource = s1 & s2 End If
Adodc2.Refresh
Do While Adodc2.Recordset.EOF = False
Combo2.AddItem Adodc2.Recordset.Fields(0) Adodc2.Recordset.MoveNext Loop End Sub
组合框(Combo2)处理(Click) Private Sub Combo2_Click()
Dim s1 As String, s2 As String, s3 As String
Set DataGrid1.DataSource = Nothing If opt = 0 Then
s1 = "select * from 学生成绩表 where 课程名称='" s2 = Combo2.Text & " ' and 学号 in (select 学号 "
s3 = "from 学生基本信息表 where 班级名称 ='" & Combo1.Text & "')" Adodc1.RecordSource = s1 & s2 & s3 Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1 Else
s1 = "select * from 学生成绩表 where 学号='" & Combo2.Text & "'" Adodc1.RecordSource = s1 Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1 End If End Sub
退出(Command1)处理(Click )
Private Sub Command1_Click() Unload Me End Sub
窗体装载处理程序(Load)
Private Sub Form_Load()
DataGrid1.AllowAddNew = False