VB数据库编程实现添加、查询、修改、删除
来源:互联网 发布:火车票生成器软件 编辑:程序博客网 时间:2024/06/05 09:52
Private Sub Command1_Click()
Form10.Hide
Form4.Show
End Sub
Private Sub Command10_Click()
For i = 0 To 7
If Text1(i).Text <> "" Then
Exit For
End If
Next i
If i = 8 Then
MsgBox ("不能保存空记录!")
Text1(0).SetFocus
Exit Sub
End If
If Text1(0).Text = "" Then
MsgBox ("年级不能为空")
Text1(0).SetFocus
Exit Sub
End If
If Text1(1).Text = "" Then
MsgBox ("姓名不能为空")
Text1(1).SetFocus
Exit Sub
End If
If Text1(2).Text = "" Then
MsgBox ("专业不能为空")
Text1(2).SetFocus
Exit Sub
End If
If Text1(3).Text = "" Then
MsgBox ("时间不能为空")
Text1(3).SetFocus
Exit Sub
End If
Adodc1.Recordset.Update
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = False
Command11.Enabled = False
For i = 0 To 7
Text1(i).Enabled = False
Next i
MsgBox ("保存成功")
End Sub
Private Sub Command11_Click()
If Adodc1.Recordset.RecordCount = 0 Then
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = False
Command11.Enabled = False
Exit Sub
End If
Adodc1.Recordset.CancelUpdate
Adodc1.Refresh
For i = 0 To 7
Text1(i).Enabled = False
Next i
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = False
Command11.Enabled = False
End Sub
Private Sub Command12_Click()
Set DataGrid1.DataSource = Adodc1
DataGrid1.Visible = True
End Sub
Private Sub Command2_Click()
If Adodc1.Recordset.RecordCount = 0 Then
Exit Sub
End If
Adodc1.Recordset.MoveFirst
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = False
Command11.Enabled = False
End Sub
Private Sub Command3_Click()
If Adodc1.Recordset.RecordCount = 0 Then
Exit Sub
End If
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = False
Command11.Enabled = False
End Sub
Private Sub Command4_Click()
If Adodc1.Recordset.RecordCount = 0 Then
Exit Sub
End If
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = False
Command11.Enabled = False
End Sub
Private Sub Command5_Click()
If Adodc1.Recordset.RecordCount = 0 Then
Exit Sub
End If
Adodc1.Recordset.MoveLast
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = False
Command11.Enabled = False
End Sub
Private Sub Command6_Click()
Adodc1.Recordset.AddNew
For i = 0 To 7
Text1(i).Enabled = True
Text1(i).Text = ""
Text1(0).SetFocus
Next i
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = True
Command11.Enabled = True
End Sub
Private Sub Command7_Click()
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox ("没有要删除的记录")
Exit Sub
End If
Dim str As String
str = MsgBox("真的要删除此记录么?", vbYesNo)
If str = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
End If
End Sub
Private Sub Command8_Click()
'On Error Resume Next
Dim str As String
'Adodc1.CursorType = adOpenDynamic
str = InputBox("请输入社员年级", "请查找")
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM 社员 WHERE 年级= '" & str & " ' "
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = " select * from 社员 "
Adodc1.Refresh
MsgBox "没有此社员", , "查找"
End If
' If
'Dim mzy As String
'mzy = InputBox("请输入年级号", "请查找")
'Adodc1.CommandType = adCmdText
'Adodc1.RecordSource = "Select * From 社员 Where 年级= '" & mzy & " '"
'Adodc1.Refresh
'If Adodc1.Recordset.EOF Then
'MsgBox "无此读者号!", , "提示"
End Sub
Private Sub Command9_Click()
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = True
Command11.Enabled = True
If Adodc1.Recordset.RecordCount <> 0 Then
For i = 0 To 7
Text1(i).Enabled = True
Next i
Else
MsgBox ("没有要修改的记录")
End If
End Sub
Private Sub Form_Load()
For i = 0 To 7
Text1(i).Enabled = False
Next i
Command10.Enabled = False
Command11.Enabled = False
End Sub
Private Sub Text2_Change()
End Sub
- VB数据库编程实现添加、查询、修改、删除
- VB ACCESS数据库的修改、删除、添加
- VB ADOBD操作access数据库 添加、修改、删除
- asp.net(VB)操作Access数据库(链接/添加/修改/删除)
- asp.net(VB)操作Access数据库(链接/添加/修改/删除)
- 连接数据库实现删除 添加 修改操作
- C#实现对数据库中的表的查询、添加、修改、删除数据
- C#实现SQL数据库中的表的查询、添加、修改、删除数据
- C#实现对SQL数据库中的表的查询、添加、修改、删除数据
- 连接数据库实现添加,删除,修改,AJAX异步,分页,查询等操作,
- Asp连接access数据库,查询,添加,修改,删除
- SQLite3数据库操作:建库,建表,添加,查询,修改,删除
- C++使用ADO2数据库类查询、添加、修改、删除操作
- C#与数据库之间的连接(查询,修改,删除,添加)
- C++使用ADO2数据库类查询、添加、修改、删除操作
- DataGridView连接Sql数据库 功能 查询 添加 删除 修改
- XML 查询、添加、修改、删除
- XML 查询、添加、修改、删除
- ASP.NET 2.0个性化配置(profile)
- Google App Engine之初窥(大杂烩-了解先)
- windows编程——画键盘
- 深入理解C++对象模型默认构造函数笔记
- windows编程——滚动条
- VB数据库编程实现添加、查询、修改、删除
- asp.net 2.0异步页面
- 遍历一个实例的所有属性,得到属性的名称和值
- Time Zone
- 设计软件测试用例的思考
- ASP.NET 委托,异步调用例子
- Flex、Java、C#、JavaFX的事件处理机制的比较
- [转帖]小保姆干预主人家的生活
- Servlet、Jsp性能优化