首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

弟刚学VB一个学期,学校让做课程设,用VB连access做学生信息管理系统,该怎么解决

2012-03-07 
弟刚学VB一个学期,学校让做课程设,用VB连access做学生信息管理系统小弟刚学VB一个学期,学校让做课程设计,

弟刚学VB一个学期,学校让做课程设,用VB连access做学生信息管理系统
小弟刚学VB一个学期,学校让做课程设计,小弟感觉很难,尤其登陆框和用户的登陆功能不会做,特来CSDN请教各位大侠,谁会的话教教小弟,不胜感激,具体要求如下
 本系统为用户管理:实现用户的添加、删除、修改、查询功能。


[解决办法]
Private Sub Commandup_Click()
If a > 5 Then
a = a - 5

sql1 = "select * from 表 where ID between " & a & " and " & a + 5 & " "
Adodc1.RecordSource = sql1
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1

End If
End Sub

Private Sub Form_Load()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim conn As ADODB.Connection
cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb"
End Sub





Private Sub cmdDelete_Click()
Dim response As Integer
response = MsgBox("删除当前记录吗?", vbQuestion + vbYesNo, "询问")
If response = vbYes Then



Adodc1.Recordset.Delete


End If


End Sub

Private Sub cmdModify_Click()

Adodc1.RecordSource = "select * from 表"
With Adodc1.Recordset

.Fields(1) = Trim$(txtXingMing.Text)
.Fields(2) = Trim$(txtNianLing.Text)
.Fields(3) = Trim$(cboXingBie.Text)
.Update
'MsgBox "信息已成功添加!", vbInformation

'MsgBox "此用户已存在!", vbExclamation

Exit Sub

End With

End Sub

Private Sub cmdSave_Click()
If Trim$(txtXingMing.Text) = "" Then
MsgBox "请输入姓名!", vbExclamation
txtXingMing.SetFocus
Exit Sub
End If
If Trim$(txtNianLing.Text) = "" Then
MsgBox "请输入年龄!", vbExclamation
txtNianLing.SetFocus

Exit Sub
End If
Adodc1.RecordSource = "select * from 表 where 姓名='" & txtXingMing.Text & "'"
Adodc1.Refresh
With Adodc1.Recordset
If .BOF Then
.AddNew
.Fields(0) = Trim$(txtXingMing.Text)
.Fields(1) = Trim$(txtNianLing.Text)
.Fields(2) = Trim$(cboXingBie.Text)
.Update

MsgBox "信息已成功添加!", vbInformation
Set DataGrid1.DataSource = Adodc1
Else
MsgBox "此用户已存在!", vbExclamation

Exit Sub
End If
End With


End Sub





Private Sub cmdSelect_Click()



If Trim$(txtXingMing.Text) = "" Then

If Trim$(txtNianLing.Text) = "" Then

 
a = 1


sql1 = "select * from 表 where ID between " & a & " and " & a + 5 & " "


Else
sql1 = "select * from 表 where 年龄='" & Trim(txtNianLing.Text) & "'"

End If
Else
sql1 = "select * from 表 where 姓名 = '" & Trim(txtXingMing.Text) & "'"


End If
Adodc1.RecordSource = sql1
Adodc1.Refresh
If Adodc1.Recordset.BOF Then
MsgBox "对不起,没有您所要查找的记录。", vbInformation
Exit Sub
End If

Set DataGrid1.DataSource = Adodc1

 
End Sub



Private Sub Commandnext_Click()
If a > 0 Then
a = a + 5

sql1 = "select * from 表 where ID between " & a & " and " & a + 5 & " "
Adodc1.RecordSource = sql1
Adodc1.Refresh
If Adodc1.Recordset.BOF Then
sql1 = "select * from 表 where ID between 1 and 6"
Adodc1.RecordSource = sql1
Adodc1.Refresh
a = 1
End If
 Set DataGrid1.DataSource = Adodc1

End If
End Sub

热点排行