1、学生信息管理系统代码主要代码如下:1、登录界面代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.RecordsetStatic i%cn.ConnectionString = Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source
2、=C1847cn.Openusna = Trim(Text1.Text)mysql = select * from 用户表 where 用户名 = & usna & rst.Open mysql, cnIf rst.EOF ThenMsgBox 用户名不存在! cn.CloseText1.Text = Text2.Text = Text1.SetFocusElseIf Trim(rst( 密码 ) = Trim(Text2.Text) Then管理界面 .ShowElsei = i + 1If i 3 ThenMsgBox 用户名或密码错误! , vbOKOnly + vbExclamatio
3、n, 做小II警告 cn.CloseText2.Text = Text1.Text = Text1.SetFocusElseMsgBox 该用户已被锁定! , vbOKOnly + vbExclamation, 告End IfEnd IfEnd IfEnd SubPrivate Sub mand2_Click()Text1.Text = Text2.Text = Text3.Text = End Sub2、管理界面代码:Private Sub Sinsert_Click()添加学生信息 .ShowEnd SubPrivate Sub Sselect_Click() 查询学生信息 .ShowEn
4、d 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 mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.Connectio
5、nString = Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847cn.OpenIf bo1.Text ThenTrim(bo1.Text) & rst.Open mysql, cnIf rst.EOF Thenbo1.Text = ElseWith MSFlexGrid1.TextMatrix(0, 1) = 学号.TextMatrix(0, 2) = 姓名.TextMatrix(0, 3) = 性别.TextMatrix(0,
6、4) = 年龄.TextMatrix(0, 5) = 系别.TextMatrix(0, 6) = 班级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(年龄).TextMatrix(.Rows - 1, 5)
7、 = rst.Fields(系别).TextMatrix(.Rows - 1, 6) = rst.Fields(班级)rst.MoveNextLoopEnd WithEnd IfElseIf bo2.Text Thenmysql = select * from 学生信息表 where 班级 = &Trim(bo2.Text) & rst.Open mysql, cnIf rst.EOF Thenbo1.Text = ElseWith MSFlexGrid1.TextMatrix(0, 1) = 学号.TextMatrix(0, 2) = 姓名.TextMatrix(0, 3) = 性别.Tex
8、tMatrix(0, 4) = 年龄.TextMatrix(0, 5) = 系别.TextMatrix(0, 6) = 班级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( 年龄 ).TextM
9、atrix(.Rows - 1, 6) = rst.Fields( 班级 )rst.MoveNextLoopEnd WithEnd IfElseIf Text1.Text Thenmysql = select * from 学生信息表 where 学号 = &Trim(Text1.Text) & rst.Open mysql, cnIf rst.EOF ThenMsgBox 没有学生 !, vbOKOnly + vbExclamation, bo1.Text = ElseWith MSFlexGrid1.TextMatrix(0, 1) = 学号TextMatrix(0, 2) = 姓名Tex
10、tMatrix(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 - 1, 2) = rst.Fields( 姓名 ).TextMatrix(.Rows - 1, 3) = rst.Fields( 性别 )
11、.TextMatrix(.Rows - 1, 4) = rst.Fields( 年龄 ).TextMatrix(.Rows - 1, 5) = rst.Fields( 系别 ).TextMatrix(.Rows - 1, 6) = rst.Fields( 班级 )rst.MoveNextLoopEnd WithEnd IfElseMsgBox 请输入查询条件 !, vbOKOnly + vbExclamation, End IfEnd SubPrivate Sub mand2_Click()bo1.Text = bo2.Text = Text1.Text = End Sub修改学生信息 .Sh
12、owEnd Sub 修改学生信息Private Sub mand4_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847cn.Openmysql = delete from 学生信息表 where 学号 = & Text1.Text & rst.Open mysql,
13、 cnMsgBox 删除成功 !, vbOKOnly + vbExclamation, 做小II警告 End SubPrivate Sub Form_Load()bo1.AddItem 信息服务学院bo1.AddItem 电子信息工程系 bo2.AddItem 40821P bo2.AddItem 40811P bo2.AddItem 40822P bo2.AddItem 40721P End Sub4、添加学生信息代码Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Form_Load() bo1.
14、AddItem 信息服务学院 bo1.AddItem 电子信息工程系 bo2.AddItem 40821P bo2.AddItem 40811P bo2.AddItem 40822P bo2.AddItem 40721P End SubSet cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1
15、847cn.OpenDim sex As Stringusna = Trim(Text1.Text)mysql = select * from学生信息表 where 学号 = & usna &rst.Open mysql, cnIf rst.EOF Thenrst.CloseElserst.CloseMsgBox 该学生信息已存在 !, vbOKOnly + vbExclamation, Text1.Text = Text2.Text = Text3.Text = bo1.Text = bo2.Text = Option1.Value = FalseText1.SetFocusEnd IfIf
16、 Text1.Text = ThenMsgBox 请输入学号! , vbOKOnly + vbExclamation, 做小II警告 Text1.SetFocusExit SubEnd IfIf Text2.Text = ThenMsgBox 请输入姓名! , vbOKOnly + vbExclamation, 做小II警告 Text2.SetFocusExit SubEnd IfIf Text3.Text = ThenMsgBox 请输入年龄! , vbOKOnly + vbExclamation, Text3.SetFocusExit SubEnd IfIf Option1.Value T
17、hensex = 男 Elsesex = 女 End Ifxh = Trim(Text1.Text) xm = Trim(Text2.Text) xb = sexnl = Trim(Text3.Text) xofy = Trim(bo1.Text) bj = Trim(bo2.Text)mysql = insert into学生信息表 (学号,姓名,性别, 年龄, 系别,班级) values ( & xh & , & xm & , & xb & , & nl & , & xofy & , & bj & )rst.Open mysql, cnMsgBox ( 信息添加成功 !)Text1.Tex
18、t = Text2.Text = Text3.Text = bo1.Text = bo2.Text = Option1.Value = FalseEnd Sub5、修改密码:Dim rst As New ADODB.RecordsetDim cn As New ADODB.ConnectionPrivate Sub mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.RecordsetIf Text1.Text = ThenMsgBox 请输入密码! , vbOKOnly + vbExclamation, Text1.Se
19、tFocusExit SubEnd If做小II警告 If Text2.Text = ThenMsgBox 请输入新密码! , vbOKOnly + vbExclamation, Text2.SetFocusExit SubEnd IfIf Text3.Text = ThenMsgBox 请确认输入的新密码! , vbOKOnly + vbExclamation, 做小II警告 Text3.SetFocusExit SubEnd IfIf Text2.Text = Text3.Text Thenxmm = Trim(Text2.Text)mysql = update 用户表 set 密码 =
20、& xmm & where 用户名 = & 登陆.Textl.Text & ”rst.Open mysql, cnMsgBox ( 密修改成功 !)End IfEnd SubPrivate Sub mand2_Click()Text1.Text = Text2.Text = Text3.Text = End Sub6、修改学生信息代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADO
21、DB.Recordsetusna = Trim(Text1.Text)mysql = select * from 学生信息表 where 学号 = & usna & rst.Open mysql, cnrst.Closemysql = delete from 学生信息表 where 学号= & Text1.Text & rst.Open mysql, cnIf Text1.Text = ThenMsgBox 请输入学号! , vbOKOnly + vbExclamation, Text1.SetFocusExit SubEnd IfIf Text2.Text = ThenMsgBox 请输入姓
22、名! , vbOKOnly + vbExclamation, Text2.SetFocusExit SubEnd IfIf Text3.Text = ThenMsgBox 请输入年龄! , vbOKOnly + vbExclamation, 做小II警告 Text3.SetFocusExit SubEnd IfIf Option1.Value Thensex = 男 Elsesex = 女 End Ifxh = Trim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)bj = Trim(bo2.Text)mysql =
23、 insert into学生信息表 (学号,姓名,性别, 年龄, 系别,班级)values ( & xh & , & xm & , & xb & , & nl & , & xofy & , & bj & )rst.Open mysql, cnMsgBox ( 信息修改成功 !)Text1.Text = Text2.Text = Text3.Text = bo1.Text = bo2.Text = Option1.Value = FalseEnd SubPrivate Sub Form_Load()bo1.AddItem 信息服务学院 bo1.AddItem 电子信息工程系 bo2.AddIte
24、m 40821Pbo2.AddItem 40811Pbo2.AddItem 40822Pbo2.AddItem 40721PEnd Sub7、用户注册代码:Dim rst As New ADODB.RecordsetDim cn As New ADODB.ConnectionPrivate Sub mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa
25、;Initial Catalog=students info;Data Source=C1847cn.OpenIf Text1.Text = ThenMsgBox 请输入用户名! , vbOKOnly + vbExclamation, 做小II警告 Text1.SetFocusExit SubEnd IfMsgBox 请输入密码! , vbOKOnly + vbExclamation, 做小II警告 Text2.SetFocusExit SubEnd IfIf Text3.Text = ThenMsgBox 请再次输入密码! , vbOKOnly + vbExclamation, 警告IITe
26、xt3.SetFocusExit SubEnd Ifsryhm = Trim(Text1.Text)srmm = Trim(Text2.Text)mysql = insert into 用户表(用户名,密码) values ( & sryhm & ,& srmm & )rst.Open mysql, cnMsgBox ( 用户添加成功 !)Text1.Text = Text2.Text = Private Sub mand2_Click()Text1.Text = Text2.Text = Text3.Text = 重置按钮End SubPrivate Sub mand3_Click()Set
27、 cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847cn.Openusna = Trim(Text1.Text)mysql = select * from 用户表 where 用户名 = & usna & rst.Open mysql, cnIf rst.EOF ThenMsgBox
28、用户名可用! ElseText1.Text = Text2.Text = Text3.Text = Text1.SetFocusExit SubEnd IfEnd Sub 检查用户名Private Sub mand4_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847cn.Openusna = Trim(Text1.Text)mysql = select * from 用户表 where 用户名 = & usna & rst.Open mysql, cnIf rst.EOF ThenMsgBox 无此用户名, 删除不成功! , vbOKOnly+ vbExclamation,II 小 II 警告 Elserst.Cl
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1