学生信息管理系统代码word资料26页.doc

上传人:1595****071 文档编号:33934688 上传时间:2022-08-12 格式:DOC 页数:26 大小:170.50KB
返回 下载 相关 举报
学生信息管理系统代码word资料26页.doc_第1页
第1页 / 共26页
学生信息管理系统代码word资料26页.doc_第2页
第2页 / 共26页
点击查看更多>>
资源描述

《学生信息管理系统代码word资料26页.doc》由会员分享,可在线阅读,更多相关《学生信息管理系统代码word资料26页.doc(26页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、如有侵权,请联系网站删除,仅供学习与交流学生信息管理系统代码【精品文档】第 26 页主要代码如下:1、登录界面代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate 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;In

2、itial 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

3、 Then MsgBox 用户名或密码错误!, vbOKOnly + vbExclamation, 警告 cn.Close Text2.Text = Text1.Text = Text1.SetFocus Else MsgBox 该用户已被锁定!, vbOKOnly + vbExclamation, 警告 End If End If End If End SubPrivate Sub Command2_Click()Text1.Text = Text2.Text = Text3.Text = End Sub2、管理界面代码:Private Sub Sinsert_Click()添加学生信息.S

4、howEnd SubPrivate Sub Sselect_Click()查询学生信息.ShowEnd SubPrivate Sub sustu_Click()查询更新学生信息.ShowEnd SubPrivate Sub xgmm_Click()修改密码.ShowEnd SubPrivate Sub yhzc_Click()用户注册.ShowEnd Sub3、查询学生信息代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click() Set cn = New ADODB.C

5、onnection 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 没

6、有学生!, 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 每次查询自动定位到第一行 Do While Not rst.EOF .Rows = .Rows + 1 .CellAlignment = 8

7、 .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

8、Combo2.Text Then mysql = select * from 学生信息表 where 班级= & Trim(Combo2.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)

9、 = 系别 .TextMatrix(0, 6) = 班级 MSFlexGrid1.Rows = 1 每次查询自动定位到第一行 Do While Not rst.EOF .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(年龄) .TextMa

10、trix(.Rows - 1, 5) = rst.Fields(系别) .TextMatrix(.Rows - 1, 6) = rst.Fields(班级) rst.MoveNext Loop End With End If ElseIf Text1.Text Then mysql = select * from 学生信息表 where 学号= & Trim(Text1.Text) & rst.Open mysql, cn If rst.EOF Then MsgBox 没有学生!, vbOKOnly + vbExclamation, 警告 Combo1.Text = Else With MSF

11、lexGrid1 .TextMatrix(0, 1) = 学号 .TextMatrix(0, 2) = 姓名 .TextMatrix(0, 3) = 性别 .TextMatrix(0, 4) = 年龄 .TextMatrix(0, 5) = 系别 .TextMatrix(0, 6) = 班级 MSFlexGrid1.Rows = 1 每次查询自动定位到第一行 Do While Not rst.EOF .Rows = .Rows + 1 .CellAlignment = 8 .TextMatrix(.Rows - 1, 1) = rst.Fields(学号) .TextMatrix(.Rows

12、- 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 IfElse MsgBox 请输入查询条件!, vbOKOnly + vbExclamation, 警告End IfEnd SubPrivate

13、 Sub Command2_Click()Combo1.Text = Combo2.Text = Text1.Text = End SubPrivate Sub Command3_Click()修改学生信息.ShowEnd Sub 修改学生信息Private Sub Command4_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial

14、Catalog=students info;Data Source=C1847 cn.Open mysql = delete from 学生信息表 where 学号= & Text1.Text & rst.Open mysql, cn MsgBox 删除成功!, vbOKOnly + vbExclamation, 警告End SubPrivate Sub Form_Load()Combo1.AddItem 信息服务学院Combo1.AddItem 电子信息工程系Combo2.AddItem 40821PCombo2.AddItem 40811PCombo2.AddItem 40822PComb

15、o2.AddItem 40721PEnd Sub4、添加学生信息代码Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Form_Load()Combo1.AddItem 信息服务学院Combo1.AddItem 电子信息工程系Combo2.AddItem 40821PCombo2.AddItem 40811PCombo2.AddItem 40822PCombo2.AddItem 40721PEnd SubPrivate Sub Command1_Click() Set cn = New ADODB.C

16、onnection 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.OpenDim sex As String usna = Trim(Text1.Text) mysql = select * from 学生信息表 where 学号= & usna & rst.Open mysql, cn If rst.EOF Then

17、rst.Close Else rst.Close MsgBox 该学生信息已存在!, vbOKOnly + vbExclamation, 警告 Text1.Text = Text2.Text = Text3.Text = Combo1.Text = Combo2.Text = Option1.Value = False Text1.SetFocus End IfIf Text1.Text = Then MsgBox 请输入学号!, vbOKOnly + vbExclamation, 警告 Text1.SetFocus Exit Sub End IfIf Text2.Text = Then Ms

18、gBox 请输入姓名!, vbOKOnly + vbExclamation, 警告 Text2.SetFocus Exit Sub End IfIf Text3.Text = Then MsgBox 请输入年龄!, vbOKOnly + vbExclamation, 警告 Text3.SetFocus Exit Sub End IfIf Option1.Value Then sex = 男 Else sex = 女End Ifxh = Trim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim(Co

19、mbo1.Text)bj = Trim(Combo2.Text)mysql = insert into 学生信息表(学号,姓名,性别,年龄,系别,班级) values ( & xh & , & xm & , & xb & , & nl & , & xofy & , & bj & )rst.Open mysql, cnMsgBox (信息添加成功!) Text1.Text = Text2.Text = Text3.Text = Combo1.Text = Combo2.Text = Option1.Value = FalseEnd Sub5、修改密码:Dim rst As New ADODB.R

20、ecordset Dim cn As New ADODB.ConnectionPrivate 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 Text1.Text = Then MsgBox 请输入密码!,

21、 vbOKOnly + vbExclamation, 警告 Text1.SetFocus Exit Sub End IfIf Text2.Text = Then MsgBox 请输入新密码!, vbOKOnly + vbExclamation, 警告 Text2.SetFocus Exit Sub End IfIf Text3.Text = Then MsgBox 请确认输入的新密码!, vbOKOnly + vbExclamation, 警告 Text3.SetFocus Exit Sub End IfIf Text2.Text = Text3.Text Thenxmm = Trim(Tex

22、t2.Text)mysql = update 用户表 set 密码 = & xmm & where 用户名 = & 登陆.Text1.Text & rst.Open mysql, cnMsgBox (密修改成功!)End If End SubPrivate Sub Command2_Click()Text1.Text = Text2.Text = Text3.Text = End Sub6、修改学生信息代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click() Set c

23、n = 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 usna = Trim(Text1.Text) mysql = select * from 学生信息表 where 学号= & usna & rst.Open mysql, cn rst.Close mysql =

24、delete from 学生信息表 where 学号= & Text1.Text & rst.Open mysql, cnIf Text1.Text = Then MsgBox 请输入学号!, vbOKOnly + vbExclamation, 警告 Text1.SetFocus Exit Sub End IfIf Text2.Text = Then MsgBox 请输入姓名!, vbOKOnly + vbExclamation, 警告 Text2.SetFocus Exit Sub End IfIf Text3.Text = Then MsgBox 请输入年龄!, vbOKOnly + vb

25、Exclamation, 警告 Text3.SetFocus Exit Sub End IfIf Option1.Value Then sex = 男 Else sex = 女End Ifxh = Trim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim(Combo1.Text)bj = Trim(Combo2.Text)mysql = insert into 学生信息表(学号,姓名,性别,年龄,系别,班级) values ( & xh & , & xm & , & xb & , & nl & ,

26、 & xofy & , & bj & )rst.Open mysql, cnMsgBox (信息修改成功!) Text1.Text = Text2.Text = Text3.Text = Combo1.Text = Combo2.Text = Option1.Value = FalseEnd SubPrivate Sub Form_Load()Combo1.AddItem 信息服务学院Combo1.AddItem 电子信息工程系Combo2.AddItem 40821PCombo2.AddItem 40811PCombo2.AddItem 40822PCombo2.AddItem 40721P

27、End Sub7、用户注册代码:Dim rst As New ADODB.Recordset Dim cn As New ADODB.ConnectionPrivate 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.Op

28、en If Text1.Text = Then MsgBox 请输入用户名!, vbOKOnly + vbExclamation, 警告 Text1.SetFocus Exit Sub End IfIf Text2.Text = Then MsgBox 请输入密码!, vbOKOnly + vbExclamation, 警告 Text2.SetFocus Exit Sub End IfIf Text3.Text = Then MsgBox 请再次输入密码!, vbOKOnly + vbExclamation, 警告 Text3.SetFocus Exit Sub End Ifsryhm = T

29、rim(Text1.Text)srmm = Trim(Text2.Text)mysql = insert into 用户表(用户名,密码) values ( & sryhm & , & srmm & )rst.Open mysql, cnMsgBox (用户添加成功!)Text1.Text = Text2.Text = Text3.Text = End Sub 添加用户Private Sub Command2_Click()Text1.Text = Text2.Text = Text3.Text = End Sub 重置按钮Private Sub Command3_Click() Set cn

30、 = 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 usna = Trim(Text1.Text) mysql = select * from 用户表 where 用户名= & usna & rst.Open mysql, cn If rst.EOF Then MsgB

31、ox 用户名可用! Else MsgBox 用户名已存在!, vbOKOnly + vbExclamation, 警告 Text1.Text = Text2.Text = Text3.Text = Text1.SetFocus Exit Sub End IfEnd Sub 检查用户名Private Sub Command4_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = Provider=SQLOLEDB.1;Persist Security Info=False

32、;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 无此用户名,删除不成功!, vbOKOnly + vbExclamation, 警告 Else rst.Close usna = Trim(Text1.Text) mysql = delete from 用户表 where 用户名= & u

33、sna & rst.Open mysql, cn MsgBox 删除成功!, vbOKOnly + vbExclamation, 警告 Text1.Text = Text2.Text = Text3.Text = Text1.SetFocus End IfEnd Sub 删除用户Private Sub Command5_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionString = Provider=SQLOLEDB.1;Persist Security Info=False;U

34、ser ID=sa;Initial Catalog=students info;Data Source=C1847 cn.Open mysql = select * from 用户表 rst.Open mysql, cn If rst.EOF Then MsgBox 出错!, vbOKOnly + vbExclamation, 警告 End If With MSFlexGrid1 .TextMatrix(0, 1) = 用户名 .TextMatrix(0, 2) = 密码 MSFlexGrid1.Rows = 1 每次查询自动定位到第一行Do While Not rst.EOF .Rows = .Rows + 1 .CellAlignment = 8 .TextMatrix(.Rows - 1, 1) = rst.Fields(用户名) .TextMatrix(.Rows - 1, 2) = rst.Fields(密码) rst.MoveNext Loop End With rst.CloseEnd Sub 查询用户表

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁