用vb+access做一个成绩查询系统,怎么按课程查询成绩

2024-12-21 14:10:07
推荐回答(2个)
回答1:

请用datacombo组件和datagrid来实现,直接在datacombo的change事件中筛选就可以了,不用多余的搜索按钮。

回答2:

Public Str1 As String
Public Str2 As String
Public Str3 As String
Private Sub Command1_Click()
Dim i as integer
Str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
Str2 = "Data Source=数据库名称;"
Str3 = "Jet OLEDB:Database Password="
i=0
conn.Open Str1 & Str2 & Str3
strSQL = "select * from 数据表名称 Where 课程名称='" & Combo1.Text & "'"
rs.Open strSQL, conn, 3, 3
While Not rs.EOF
dataGrid1.Text(i, 0) = rs!学生姓名
dataGrid1.Text(i, 1) = rs!成绩
i=i+1
rs.MoveNext
Wend
rs.close
conn.close
End Sub

VB6.0程序