学生信息管理系统代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

主要代码如下:

1、登录界面代码:

Dim cn As New ADODB.Connection

Dim rst As New ADODB.Recordset

Private Sub Command1_Click()

Set cn = New ADODB.Connection

Set rst = New ADODB.Recordset

Static i%

cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security

Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"

cn.Open

usna = Trim(Text1.Text)

mysql = "select * from 用户表 where 用户名='" & usna & "'"

rst.Open mysql, cn

If rst.EOF Then

MsgBox "用户名不存在!"

cn.Close

Text1.Text = ""

Text2.Text = ""

Text1.SetFocus

Else

If Trim(rst("密码")) = Trim(Text2.Text) Then

管理界面.Show

Else

i = i + 1

If i < 3 Then

MsgBox "用户名或密码错误!", vbOKOnly + vbExclamation, "警告"

cn.Close

Text2.Text = ""

Text1.Text = ""

Text1.SetFocus

Else

MsgBox "该用户已被锁定!", vbOKOnly + vbExclamation, "警告"

End If

End If

End If

End Sub

Private Sub Command2_Click() Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

End Sub

2、管理界面代码:

Private Sub Sinsert_Click() 添加学生信息.Show

End Sub

Private Sub Sselect_Click() 查询学生信息.Show

End Sub

Private Sub sustu_Click()

查询更新学生信息.Show

End Sub

Private Sub xgmm_Click()

修改密码.Show

End Sub

Private Sub yhzc_Click()

用户注册.Show

End Sub

3、查询学生信息代码:

Dim cn As New ADODB.Connection

Dim rst As New ADODB.Recordset

Private Sub Command1_Click()

Set cn = New ADODB.Connection

Set rst = New ADODB.Recordset

cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security

Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"

cn.Open

If Combo1.Text <> "" Then

mysql = "select * from 学生信息表 where 系别='" & Trim(Combo1.Text) & "'"

rst.Open mysql, cn

If rst.EOF Then

MsgBox "没有学生!", vbOKOnly + vbExclamation, "警告"

Combo1.Text = ""

Else

With MSFlexGrid1

.TextMatrix(0, 1) = "学号"

.TextMatrix(0, 2) = "姓名"

.TextMatrix(0, 3) = "性别"

.TextMatrix(0, 4) = "年龄"

.TextMatrix(0, 5) = "系别"

.TextMatrix(0, 6) = "班级"

MSFlexGrid1.Rows = 1 '每次查询自动定位到第一行

.Rows = .Rows + 1

.CellAlignment = 8

.TextMatrix(.Rows - 1, 1) = rst.Fields("学号")

.TextMatrix(.Rows - 1, 2) = rst.Fields("姓名")

.TextMatrix(.Rows - 1, 3) = rst.Fields("性别")

.TextMatrix(.Rows - 1, 4) = rst.Fields("年龄")

.TextMatrix(.Rows - 1, 5) = rst.Fields("系别")

.TextMatrix(.Rows - 1, 6) = rst.Fields("班级")

rst.MoveNext

Loop

End With

End If

ElseIf Combo2.Text <> "" Then

mysql = "select * from 学生信息表 where 班级='" & Trim(Combo2.Text) & "'"

rst.Open mysql, cn

相关文档
最新文档