學(xué)生信息管理系統(tǒng)代碼_第1頁
學(xué)生信息管理系統(tǒng)代碼_第2頁
學(xué)生信息管理系統(tǒng)代碼_第3頁
學(xué)生信息管理系統(tǒng)代碼_第4頁
已閱讀5頁,還剩23頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

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=C18

2、47"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(Text

3、2.Text) Then管理界面 .ShowElsei = i + 1If i < 3 ThenMsgBox "用戶名或密碼錯(cuò)誤! ", vbOKOnly + vbExclamation, "警告 "cn.CloseText2.Text = ""Text1.Text = ""Text1.SetFocusElseMsgBox "該用戶已被鎖定! ", vbOKOnly + vbExclamation, "警告 "End IfEnd IfEnd IfEnd SubPriva

4、te Sub mand2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub2、管理界面代碼:Private Sub Sinsert_Click()添加學(xué)生信息 .ShowEnd SubPrivate Sub Sselect_Click()查詢學(xué)生信息 .ShowEnd SubPrivate Sub sustu_Click()查詢更新學(xué)生信息 .ShowEnd SubPrivate Sub xgmm_Click()修改密碼 .ShowEnd SubPrivate Su

5、b yhzc_Click()用戶注冊(cè) .ShowEnd Sub3、查詢學(xué)生信息代碼: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 Security Info=False;User ID=sa;Initial Catalog=students inf

6、o;Data Source=C1847"cn.OpenIf bo1.Text <> "" Thenmysql = "select * from學(xué)生信息表where系別 ='" &Trim(bo1.Text) & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "沒有學(xué)生 !", vbOKOnly + vbExclamation, "警告 "bo1.Text = ""ElseWith M

7、SFlexGrid1.TextMatrix(0, 1) = "學(xué)號(hào) ".TextMatrix(0, 2) = "姓名 ".TextMatrix(0, 3) = "性別 ".TextMatrix(0, 4) = "年齡 ".TextMatrix(0, 5) = "系別 ".TextMatrix(0, 6) = "班級(jí) "MSFlexGrid1.Rows = 1 'Do While Not rst.EOF.Rows = .Rows + 1每次查詢自動(dòng)定位到第一行.Cell

8、Alignment = 8.TextMatrix(.Rows - 1, 1) = rst.Fields("學(xué)號(hào) ").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(

9、.Rows - 1, 6) = rst.Fields("班級(jí) ")rst.MoveNextLoopEnd WithEnd IfElseIf bo2.Text <> "" Thenmysql = "select * from學(xué)生信息表 where班級(jí) ='" &Trim(bo2.Text) & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "沒有學(xué)生 !", vbOKOnly + vbExclamation, &q

10、uot;警告 "bo1.Text = ""ElseWith MSFlexGrid1.TextMatrix(0, 1) = "學(xué)號(hào) ".TextMatrix(0, 2) = "姓名 ".TextMatrix(0, 3) = "性別 ".TextMatrix(0, 4) = "年齡 ".TextMatrix(0, 5) = "系別 ".TextMatrix(0, 6) = "班級(jí) "MSFlexGrid1.Rows = 1 '每次查詢自動(dòng)定位

11、到第一行Do While Not rst.EOF.Rows = .Rows + 1.CellAlignment = 8.TextMatrix(.Rows - 1, 1) = rst.Fields("學(xué)號(hào) ").TextMatrix(.Rows - 1, 2) = rst.Fields("姓名 ").TextMatrix(.Rows - 1, 3) = rst.Fields("性別 ").TextMatrix(.Rows - 1, 4) = rst.Fields("年齡 ").TextMatrix(.Rows - 1

12、, 5) = rst.Fields("系別 ").TextMatrix(.Rows - 1, 6) = rst.Fields("班級(jí) ")rst.MoveNextLoopEnd WithEnd IfElseIf Text1.Text <> "" Thenmysql = "select * from學(xué)生信息表 where學(xué)號(hào) ='" &Trim(Text1.Text) & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBo

13、x "沒有學(xué)生 !", vbOKOnly + vbExclamation, "警告 "bo1.Text = ""ElseWith MSFlexGrid1.TextMatrix(0, 1) = "學(xué)號(hào) ".TextMatrix(0, 2) = "姓名 ".TextMatrix(0, 3) = "性別 ".TextMatrix(0, 4) = "年齡 ".TextMatrix(0, 5) = "系別 ".TextMatrix(0, 6) =

14、 "班級(jí) "MSFlexGrid1.Rows = 1 '每次查詢自動(dòng)定位到第一行Do While Not rst.EOF.Rows = .Rows + 1.CellAlignment = 8.TextMatrix(.Rows - 1, 1) = rst.Fields("學(xué)號(hào) ").TextMatrix(.Rows - 1, 2) = rst.Fields("姓名 ").TextMatrix(.Rows - 1, 3) = rst.Fields("性別 ").TextMatrix(.Rows - 1, 4)

15、= rst.Fields("年齡 ").TextMatrix(.Rows - 1, 5) = rst.Fields("系別 ").TextMatrix(.Rows - 1, 6) = rst.Fields("班級(jí) ")rst.MoveNextLoopEnd WithEnd IfElseMsgBox "請(qǐng)輸入查詢條件 !", vbOKOnly + vbExclamation, "警告 "End IfEnd SubPrivate Sub mand2_Click()bo1.Text = "&

16、quot;bo2.Text = ""Text1.Text = ""End SubPrivate Sub mand3_Click()修改學(xué)生信息 .ShowEnd Sub'修改學(xué)生信息Private Sub mand4_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog

17、=students info;Data Source=C1847"cn.Openmysql = "delete from學(xué)生信息表 where學(xué)號(hào) ='" & Text1.Text & "'"rst.Open mysql, cnMsgBox "刪除成功 !", vbOKOnly + vbExclamation, "警告 "End SubPrivate Sub Form_Load()bo1.AddItem " 信息服務(wù)學(xué)院 "bo1.AddItem &qu

18、ot; 電子信息工程系 "bo2.AddItem "40821P"bo2.AddItem "40811P"bo2.AddItem "40822P"bo2.AddItem "40721P"End Sub4、添加學(xué)生信息代碼Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Form_Load()bo1.AddItem " 信息服務(wù)學(xué)院 "bo1.AddItem " 電子信息工程系 &qu

19、ot;bo2.AddItem "40821P"bo2.AddItem "40811P"bo2.AddItem "40822P"bo2.AddItem "40721P"End SubPrivate Sub mand1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;

20、Initial Catalog=students info;Data Source=C1847"cn.OpenDim sex As Stringusna = Trim(Text1.Text)mysql = "select * from學(xué)生信息表 where學(xué)號(hào) ='" & usna & "'"rst.Open mysql, cnIf rst.EOF Thenrst.CloseElserst.CloseMsgBox "該學(xué)生信息已存在 !", vbOKOnly + vbExclamation,

21、"警告 "Text1.Text = ""Text2.Text = ""Text3.Text = ""bo1.Text = ""bo2.Text = ""Option1.Value = FalseText1.SetFocusEnd IfIf Text1.Text = "" ThenMsgBox "請(qǐng)輸入學(xué)號(hào)! ", vbOKOnly + vbExclamation, "警告 "Text1.SetFocusExit Su

22、bEnd IfIf Text2.Text = "" ThenMsgBox "請(qǐng)輸入姓名! ", vbOKOnly + vbExclamation, "警告 "Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "請(qǐng)輸入年齡! ", vbOKOnly + vbExclamation, "警告 "Text3.SetFocusExit SubEnd IfIf Option1.Value Thensex = "

23、男"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學(xué)生信息表 ( 學(xué)號(hào) , 姓名 , 性別 , 年齡 , 系別 , 班級(jí) )values ('" & xh & "','" & xm & "','

24、" & xb & "','" & nl & "','" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox (" 信息添加成功 !")Text1.Text = ""Text2.Text = ""Text3.Text = ""bo1.Text = "&

25、quot;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.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial

26、 Catalog=students info;Data Source=C1847"cn.OpenIf Text1.Text = "" ThenMsgBox "請(qǐng)輸入密碼! ", vbOKOnly + vbExclamation, "警告 "Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "請(qǐng)輸入新密碼! ", vbOKOnly + vbExclamation, "警告 "Text2.SetFocus

27、Exit SubEnd IfIf Text3.Text = "" ThenMsgBox "請(qǐng)確認(rèn)輸入的新密碼! ", vbOKOnly + vbExclamation, "警告 "Text3.SetFocusExit SubEnd IfIf Text2.Text = Text3.Text Thenxmm = Trim(Text2.Text)mysql = "update用戶表 set密碼 = '" & xmm & "' where用戶名 = '" &

28、;登陸 .Text1.Text & "'"rst.Open mysql, cnMsgBox (" 密修改成功 !")End IfEnd SubPrivate Sub mand2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub6、修改學(xué)生信息代碼:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub mand1_Click

29、()Set 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=C1847"cn.Openusna = Trim(Text1.Text)mysql = "select * from學(xué)生信息表 where學(xué)號(hào) ='" & usna &

30、 "'"rst.Open mysql, cnrst.Closemysql = "delete from學(xué)生信息表where學(xué)號(hào) ='" & Text1.Text & "'"rst.Open mysql, cnIf Text1.Text = "" ThenMsgBox "請(qǐng)輸入學(xué)號(hào)! ", vbOKOnly + vbExclamation, "警告 "Text1.SetFocusExit SubEnd IfIf Text2.Text =

31、"" ThenMsgBox "請(qǐng)輸入姓名! ", vbOKOnly + vbExclamation, "警告 "Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "請(qǐng)輸入年齡! ", vbOKOnly + vbExclamation, "警告 "Text3.SetFocusExit SubEnd IfIf Option1.Value Thensex = "男"Elsesex = "

32、女"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學(xué)生信息表 ( 學(xué)號(hào) , 姓名 , 性別 , 年齡 , 系別 , 班級(jí) )values ('" & xh & "','" & xm & "','" & xb & &

33、quot;','" & nl & "','" & xofy &"','" & bj & "')"rst.Open mysql, cnMsgBox (" 信息修改成功 !")Text1.Text = ""Text2.Text = ""Text3.Text = ""bo1.Text = ""bo2.Text = "&q

34、uot;Option1.Value = FalseEnd SubPrivate Sub Form_Load()bo1.AddItem " 信息服務(wù)學(xué)院 "bo1.AddItem " 電子信息工程系 "bo2.AddItem "40821P"bo2.AddItem "40811P"bo2.AddItem "40822P"bo2.AddItem "40721P"End Sub7、用戶注冊(cè)代碼:Dim rst As New ADODB.RecordsetDim cn As New

35、ADODB.ConnectionPrivate Sub mand1_Click()Set 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=C1847"cn.OpenIf Text1.Text = "" ThenMsgBox "請(qǐng)輸入用戶名!

36、", vbOKOnly + vbExclamation, "警告 "Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "請(qǐng)輸入密碼! ", vbOKOnly + vbExclamation, "警告 "Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "請(qǐng)?jiān)俅屋斎朊艽a! ", vbOKOnly + vbExclamation, &quo

37、t;警告"Text3.SetFocusExit SubEnd Ifsryhm = Trim(Text1.Text)srmm = Trim(Text2.Text)mysql = "insert into用戶表 ( 用戶名 , 密碼 ) values ('" & sryhm & "','"& srmm & "')"rst.Open mysql, cnMsgBox (" 用戶添加成功 !")Text1.Text = ""Text

38、2.Text = ""Text3.Text = ""End Sub'添加用戶Private Sub mand2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub'重置按鈕Private Sub mand3_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQ

39、LOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.Openusna = Trim(Text1.Text)mysql = "select * from用戶表where用戶名 ='" & usna & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "用戶名可用! "ElseMsgBox "用戶名已存在!

40、 ", 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 Se

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論