版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流学生信息管理系统代码.精品文档.主要代码如下: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
2、=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 = ""
3、; 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 "该用户已被锁定!", vbO
4、KOnly + vbExclamation, "警告" End If End If End If End SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub2、管理界面代码:Private Sub Sinsert_Click()添加学生信息.ShowEnd SubPrivate Sub Sselect_Click()查询学生信息.ShowEnd SubPrivate Sub sustu_Click()
5、查询更新学生信息.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.Connection Set rst = New ADODB.Recordset cn.ConnectionString = "Provider=SQL
6、OLEDB.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 &quo
7、t;没有学生!", 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) =
8、"班级" 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,
9、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)
10、 & "'" 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) =
11、 "年龄" .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 - 1, 2) = rst.Fields("姓名") .TextMa
12、trix(.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 Text1.Text <> "" Then mysql =
13、"select * from 学生信息表 where 学号='" & Trim(Text1.Text) & "'" rst.Open mysql, cn If rst.EOF Then MsgBox "没有学生!", vbOKOnly + vbExclamation, "警告" Combo1.Text = "" Else With MSFlexGrid1 .TextMatrix(0, 1) = "学号" .TextMatrix(0, 2) =
14、"姓名" .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("学号&
15、quot;) .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
16、End With End IfElse MsgBox "请输入查询条件!", vbOKOnly + vbExclamation, "警告"End IfEnd SubPrivate Sub Command2_Click()Combo1.Text = ""Combo2.Text = ""Text1.Text = ""End SubPrivate Sub Command3_Click()修改学生信息.ShowEnd Sub '修改学生信息Private Sub Command4_Click()
17、 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 mysql = "delete from 学生信息表 where 学号='" & Text1.Text & "'&qu
18、ot; rst.Open mysql, cn MsgBox "删除成功!", vbOKOnly + vbExclamation, "警告"End SubPrivate Sub Form_Load()Combo1.AddItem "信息服务学院"Combo1.AddItem "电子信息工程系"Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem
19、"40721P"End Sub4、添加学生信息代码Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Form_Load()Combo1.AddItem "信息服务学院"Combo1.AddItem "电子信息工程系"Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem &
20、quot;40721P"End SubPrivate 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.OpenDim sex As String usna = Trim(Text1.Tex
21、t) mysql = "select * from 学生信息表 where 学号='" & usna & "'" rst.Open mysql, cn If rst.EOF Then rst.Close Else rst.Close MsgBox "该学生信息已存在!", vbOKOnly + vbExclamation, "警告" Text1.Text = "" Text2.Text = "" Text3.Text = ""
22、; 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 MsgBox "请输入姓名!", vbOKOnly
23、 + 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(Te
24、xt2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim(Combo1.Text)bj = Trim(Combo2.Text)mysql = "insert into 学生信息表(学号,姓名,性别,年龄,系别,班级) values ('" & xh & "','" & xm & "','" & xb & "','" & nl & "',&
25、#39;" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox ("信息添加成功!") Text1.Text = "" Text2.Text = "" Text3.Text = "" Combo1.Text = "" Combo2.Text = "" Option1.Value = FalseEnd Sub5、修改密码:D
26、im 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.Open If
27、 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 Msg
28、Box "请确认输入的新密码!", vbOKOnly + vbExclamation, "警告" Text3.SetFocus Exit Sub End IfIf Text2.Text = Text3.Text Thenxmm = Trim(Text2.Text)mysql = "update 用户表 set 密码 = '" & xmm & "' where 用户名 = '" & 登陆.Text1.Text & "'"rst.Ope
29、n 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 cn = New ADODB.Connection Set rst
30、= 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,
31、 cn rst.Close mysql = "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 &
32、quot;请输入姓名!", 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 = T
33、rim(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 & "','" &
34、amp; nl & "','" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox ("信息修改成功!") Text1.Text = "" Text2.Text = "" Text3.Text = "" Combo1.Text = "" Combo2.Text = "" Option1.V
35、alue = FalseEnd SubPrivate Sub Form_Load()Combo1.AddItem "信息服务学院"Combo1.AddItem "电子信息工程系"Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem "40721P"End Sub7、用户注册代码:Dim rst As New ADODB.Recordset Dim cn As Ne
36、w 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 &qu
37、ot;请输入用户名!", 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 + vbExc
38、lamation, "警告" Text3.SetFocus Exit Sub End Ifsryhm = Trim(Text1.Text)srmm = Trim(Text2.Text)mysql = "insert into 用户表(用户名,密码) values ('" & sryhm & "','" & srmm & "')"rst.Open mysql, cnMsgBox ("用户添加成功!")Text1.Text = &quo
39、t;"Text2.Text = ""Text3.Text = "" End Sub '添加用户Private Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub '重置按钮Private Sub Command3_Click() Set cn = New ADODB.Connection Set rst = New ADODB.Recordset cn.ConnectionSt
40、ring = "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 "用户名可用
41、!" 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 Secu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- Unit6 知识梳理-2023-2024学年九年级英语上册(牛津译林版)
- 2026年医疗特许经营合同
- 医护人员艾滋病职业暴露防护与处理
- 浙江省桐乡市第一中学2026届化学高一上期中调研模拟试题含解析
- 四川省康定市2025年高一物理第一学期期末学业质量监测试题含解析
- 山东省聊城文轩中学2026届高二上化学期末考试模拟试题含解析
- 山东省夏津县第一中学2025-2026学年数学高一上期末教学质量检测试题含解析
- Starter Unit 3 单元易错综合测试-2023-2024学年七年级英语上册(人教版)
- 从新生儿二便护理开始培养良好习惯
- 昏迷患者病情观察与意识状态评估
- 2025天津公务员考试申论试题(行政执法类)及答案
- JJF 1107-2003测量人体温度的红外温度计校准规范
- 工程实测实量表(垂直平整度)
- 管道风险评估单
- (完整word版)高考英语作文练习纸(标准答题卡)
- 机电安装竣工全部表格
- 四年级综合实践《创建我们自己的阅读银行》教案和教学设计
- 单位用餐券模板(可编辑修改)
- 装饰石材露天矿山技术规范
- 《提高内墙饰面砖铺贴施工合格率》QC成果汇报
- (义务教育英语课程标准(2022年版))贯彻落实(英语)新课标PPT新版义务教育英语课程标准(2022年版)课件
评论
0/150
提交评论