用ACCESS和VB做学生成绩查询系统~数据库已做好~VB的代码该怎么写~(包括学号,姓名,班级查询) 跪求高手
数据库,学生表包括学号,姓名,班级;课程表包括课程号,课程名称,课程学分,开设学期,成绩表包括学号,课程号,成绩~...
数据库,学生表包括学号,姓名,班级;课程表包括课程号,课程名称,课程学分,开设学期,成绩表包括学号,课程号,成绩~
展开
2个回答
展开全部
很简单呀! 你先启动VisualBasic6.0 然后 创立标准EXE
添加 access 数据的控件 添加的方法。 第一进入 "工程(P)" → "引用(N)" ... 打开窗口找到 Microsoft ActiveX Datam Objects 2.0 Library 选择(打对号), FORM1 添加一个Listbox控件,然后打开“查看代码” 窗口 输入下面的代码:
Public imu As Boolean
Public flag As Integer 'ìí?óoíDT??μ?±ê??
Public iflag As Integer 'êy?Y?aê?2?′ò?a±ê??
Public RS As ADODB.Recordset
Public SQL As String
Public Function TransactSQL(ByVal SQL As String) As ADODB.Recordset
Dim con As ADODB.Connection
Dim RS As ADODB.Recordset
Dim strConnection As String
Dim strArray() As String
Set con = New ADODB.Connection '′′?¨á??ó
Set RS = New ADODB.Recordset '′′?¨?????ˉ
On Error GoTo TransactSQL_Error
strConnection = "Provider=Microsoft.jet.oledb.4.0;Data Sourc e=" & "D:\Test.mdb;persist security info=false; jet oledb:database password=pnurkim32"
strArray = Split(SQL)
con.Open strConnection '′ò?aá??ó
If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
RS.Open Trim$(SQL), con, adOpenKeyset, adLockOptimistic
Set TransactSQL = RS '·μ???????ˉ
iflag = 1
Else
con.Execute SQL '?′DD?üá?
iflag = 1
End If
TransactSQL_Exit:
Set RS = Nothing
Set con = Nothing
Exit Function
TransactSQL_Error:
MsgBox "2é?ˉ′í?ó£o" & Err.Description
iflag = 2
Resume TransactSQL_Exit
End Function
Sub Display()
SQL = "select * from Words" ‘ Words是Test数据文件的某一个表
Set RS = TransactSQL(SQL)
If RS.EOF = True Then
RS.MoveFirst
Else
While Not RS.EOF
List1.AddItem RS.Fields("English") ‘ Engilis 表示 Words表的某一个趔
RS.MoveNext
Wend
End If
RS.Close
End Sub
Private Sub Form_Load()
Display
End Sub
试试吧!
添加 access 数据的控件 添加的方法。 第一进入 "工程(P)" → "引用(N)" ... 打开窗口找到 Microsoft ActiveX Datam Objects 2.0 Library 选择(打对号), FORM1 添加一个Listbox控件,然后打开“查看代码” 窗口 输入下面的代码:
Public imu As Boolean
Public flag As Integer 'ìí?óoíDT??μ?±ê??
Public iflag As Integer 'êy?Y?aê?2?′ò?a±ê??
Public RS As ADODB.Recordset
Public SQL As String
Public Function TransactSQL(ByVal SQL As String) As ADODB.Recordset
Dim con As ADODB.Connection
Dim RS As ADODB.Recordset
Dim strConnection As String
Dim strArray() As String
Set con = New ADODB.Connection '′′?¨á??ó
Set RS = New ADODB.Recordset '′′?¨?????ˉ
On Error GoTo TransactSQL_Error
strConnection = "Provider=Microsoft.jet.oledb.4.0;Data Sourc e=" & "D:\Test.mdb;persist security info=false; jet oledb:database password=pnurkim32"
strArray = Split(SQL)
con.Open strConnection '′ò?aá??ó
If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
RS.Open Trim$(SQL), con, adOpenKeyset, adLockOptimistic
Set TransactSQL = RS '·μ???????ˉ
iflag = 1
Else
con.Execute SQL '?′DD?üá?
iflag = 1
End If
TransactSQL_Exit:
Set RS = Nothing
Set con = Nothing
Exit Function
TransactSQL_Error:
MsgBox "2é?ˉ′í?ó£o" & Err.Description
iflag = 2
Resume TransactSQL_Exit
End Function
Sub Display()
SQL = "select * from Words" ‘ Words是Test数据文件的某一个表
Set RS = TransactSQL(SQL)
If RS.EOF = True Then
RS.MoveFirst
Else
While Not RS.EOF
List1.AddItem RS.Fields("English") ‘ Engilis 表示 Words表的某一个趔
RS.MoveNext
Wend
End If
RS.Close
End Sub
Private Sub Form_Load()
Display
End Sub
试试吧!
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询