




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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 SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C184
2、7"cn.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(Te
3、xt2.Text) Then管理界面 .ShowElseIf i < 3 ThenMsgBox "用户名或密码错误! ", vbOKOnly + vbExclamation, "牛 II警告 "cn.CloseText2.Text =IlliText1.Text =IlliText1.SetFocusElseMsgBox "该用户已被锁定! ", vbOKOnly + vbExclamation, "警告"End IfEnd IfEnd IfEnd SubPrivate Sub mand2_Click()Te
4、xt1.Text = ""Text2.Text = ""Text3.Text = ""End Sub 2、管理界面代码:Private Sub Sinsert_Click()添加学生信息 .ShowEnd SubPrivate Sub Sselect_Click()查询学生信息 .ShowEnd SubPrivate Sub sustu_Click()查询更新学生信息 .ShowEnd SubPrivate Sub xgmm_Click()修改密码 .ShowEnd SubPrivate Sub yhzc_Click()用户注册 .S
5、howEnd Sub 3、查询学生信息代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub mand1_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=C1847&q
6、uot;cn.OpenIf bo1.Text <> "" Thenmysql = "select * from学生信息表 where 系别='" &Trim(bo1.Text) & "'"rst.Open mysql, cn做小H警告 "If rst.EOF ThenMsgBox " 没有学生!", vbOKOnly + vbExclamation, "bo1.Text = ""ElseWith MSFlexGrid1.TextMa
7、trix(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.TextMatr
8、ix(.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(
9、"班级")rst.MoveNextLoopEnd WithEnd IfElseIf bo2.Text <> "" Thenmysql = "select * from学生信息表 where 班级='" &Trim(bo2.Text) & "'"rst.Open mysql, cn做小H警告 "If rst.EOF ThenMsgBox " 没有学生!", vbOKOnly + vbExclamation, "bo1.Text = &
10、quot;"ElseWith 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 =
11、 .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("系别").T
12、extMatrix(.Rows - 1, 6) = rst.Fields("班级")rst.MoveNextLoopEnd WithEnd Ifmysql = "select * from学生信息表 where 学号='" &ElseIf Text1.Text <> "" ThenTrim(Text1.Text) & "'"rst.Open mysql, cn做小H警告 "If rst.EOF ThenMsgBox " 没有学生!", vbO
13、KOnly + vbExclamation, "bo1.Text = ""ElseWith MSFlexGrid1.TextMatrix(0, 1) = "学号".TextMatrix(0, 2) = "姓名".TextMatrix(0, 3) = "性别".TextMatrix(0, 4) = "年龄".TextMatrix(0, 5) = "系别".TextMatrix(0, 6) = "班级"MSFlexGrid1.Rows = 1
14、9;每次查询自动定位到第一行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(.Ro
15、ws - 1, 5) = rst.Fields("系别").TextMatrix(.Rows - 1, 6) = rst.Fields("班级")rst.MoveNextLoopEnd WithE_seMsgBox - 涵丰 二 <boKon-y + vbEXC-amaHOPEnd Subprisfe Sub mand2lc=ck()bol.Texf;b02.Texf H =TexH .Texf H =End Subprisfe Sub mand3lc=ck()修改学生信息 .ShowEnd Sub修改学生信息Private Sub mand4_C
16、lick()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=C1847"cn.Openmysql = "delete from 学生信息表 where 学号='" & Text1.Text & "'&qu
17、ot;做小H警告 "rst.Open mysql, cnMsgBox " 删除成功 !", vbOKOnly + vbExclamation, "End SubPrivate Sub Form_Load()bo1.AddItem " 信息服务学院 "bo1.AddItem " 电子信息工程系 "bo2.AddItem "40821P"bo2.AddItem "40811P"bo2.AddItem "40822P"bo2.AddItem "4072
18、1P"End Sub4、添加学生信息代码Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Form_Load()bo1.AddItem " 信息服务学院 "bo1.AddItem " 电子信息工程系 "bo2.AddItem "40821P"bo2.AddItem "40811P"bo2.AddItem "40822P"bo2.AddItem "40721P"End Sub
19、Private Sub mand1_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=C1847"cn.OpenDim sex As Stringusna = Trim(Text1.Text)mysql = "select * from学生信息
20、表 where 学号='" & usna & "'"rst.Open mysql, cnIf rst.EOF Thenrst.CloseElserst.CloseMsgBox " 该学生信息已存在 !", vbOKOnly + vbExclamation, "警告"Text1.Text = ""Text2.Text = ""Text3.Text = "" bo1.Text = "" bo2.Text = "
21、;"Option1.Value = FalseText1.SetFocusEnd If做小H警告 "做小H警告 "If Text1.Text = "" ThenMsgBox "请输入学号! ", vbOKOnly + vbExclamation, "Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请输入姓名! ", vbOKOnly + vbExclamation, "Text2.SetFocus
22、Exit SubEnd If做小H警告 "If Text3.Text = "" ThenMsgBox "请输入年龄! ", vbOKOnly + vbExclamation, "Text3.SetFocusExit SubEnd IfIf Option1.Value Thensex = " 男"Elsesex = " 女"End Ifxh = Trim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim
23、(bo1.Text)bj = Trim(bo2.Text)mysql = "insert into学生信息表 (学号,姓名,性别, 年龄, 系别,班级)cn.Openvalues ('" & xh & "','" & xm & "','" & xb & "','" & nl & "','" & xofy & "','&q
24、uot; & bj & "')"rst.Open mysql, cnMsgBox ("信息添加成功 !")Text1.Text = ""Text2.Text = ""Text3.Text = "" bo1.Text = "" bo2.Text = ""Option1.Value = FalseEnd Sub5、修改密码:Dim rst As New ADODB.RecordsetDim cn As New ADODB.Connect
25、ionPrivate Sub mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security做小H警告 "做小H警告 "If Text1.Text = "" ThenMsgBox "请输入密码! ", vbOKOnly + vbExclamation, "Text1.SetFocusExit SubEnd IfIf Te
26、xt2.Text = "" ThenMsgBox "请输入新密码! ", vbOKOnly + vbExclamation, "Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox " 请确认输入的新密码! ", vbOKOnly + vbExclamation, "做小H警告 "Text3.SetFocusExit SubEnd IfIf Text2.Text = Text3.Text Thenxmm = Trim(Tex
27、t2.Text)mysql = "update 用户表 set 密码 = '" & xmm & "' where 用户名 = '" &登陆.TextI.Text & "”'rst.Open mysql, cnMsgBox ("密修改成功 !")End IfEnd SubPrivate Sub mand2_Click()Text1.Text =IlliText2.Text =IlliText3.Text =IlliEnd Sub6、修改学生信息代码:Dim cn
28、As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist Securityusna = Trim(Text1.Text)做小H警告 "做小H警告 "mysql = "select * from学生信息表 where 学号='"
29、 & usna & "'"rst.Open mysql, cnrst.Closemysql = "delete from 学生信息表 where 学号='" & Text1.Text & "'"rst.Open mysql, cnIf Text1.Text = "" ThenMsgBox "请输入学号! ", vbOKOnly + vbExclamation, "Text1.SetFocusExit SubEnd IfIf Tex
30、t2.Text = "" ThenMsgBox "请输入姓名! ", vbOKOnly + vbExclamation, "Text2.SetFocusExit SubEnd If做小H警告 "If Text3.Text = "" ThenMsgBox "请输入年龄! ", vbOKOnly + vbExclamation, "Text3.SetFocusExit SubEnd IfIf Option1.Value Thensex = " 男"Elsesex = &
31、quot; 女"End Ifxh = Trim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)bj = Trim(bo2.Text)xofy = Trim(bo1.Text)mysql = "insert into学生信息表 (学号,姓名,性别, 年龄, 系别,班级)values ('" & xh & "','" & xm & "','" & xb & "
32、;','" & nl & "','" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox ("信息修改成功 !")Text1.Text =IlliText2.Text =IlliText3.Text =Illibo1.Text = "" bo2.Text = ""Option1.Value = FalseEnd S
33、ubPrivate Sub Form_Load()bo1.AddItem " 信息服务学院 "bo1.AddItem " 电子信息工程系 "bo2.AddItem "40821P"bo2.AddItem "40811P"bo2.AddItem "40822P"bo2.AddItem "40721P"End Sub7、用户注册代码:Dim rst As New ADODB.RecordsetDim cn As New ADODB.ConnectionPrivate Sub ma
34、nd1_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=C1847"cn.Open做小H警告 "If Text1.Text = "" ThenMsgBox "请输入用户名! ", vbOKOnly +
35、vbExclamation, "Text1.SetFocusExit SubEnd IfIf Text2.Text = "" Then做小H警告 "MsgBox "请输入密码! ", vbOKOnly + vbExclamation, "Text2.SetFocusExit SubEnd If警告If Text3.Text = "" ThenMsgBox " 请再次输入密码! ", vbOKOnly + vbExclamation, "IIText3.Text =IlliEn
36、d Sub添加用户Text3.SetFocusExit SubEnd Ifsryhm = Trim(Text1.Text)srmm = Trim(Text2.Text)mysql = "insert into用户表(用户名,密码) values ('" & sryhm & "','"& srmm & "')"rst.Open mysql, cnMsgBox (" 用户添加成功 !")Text1.Text =IlliText2.Text =Illi做小H
37、警告 "Private Sub mand2_Click()Text1.Text =IlliText2.Text =IlliText3.Text =IlliEnd Sub重置按钮Private Sub mand3_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 Sou
38、rce=C1847"cn.Openusna = Trim(Text1.Text)mysql = "select * from用户表 where 用户名='" & usna & "'" rst.Open mysql, cnIf rst.EOF ThenMsgBox " 用户名可用! "ElseMsgBox "用户名已存在! ", vbOKOnly + vbExclamation, "Text1.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 Catal
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论