vb 用adodc控件查询和修改access数据库中的表信息

 我来答
何书泽
2010-01-11
知道答主
回答量:9
采纳率:100%
帮助的人:1.2万
展开全部
Private Sub Command3_Click()
Adodc1.Recordset.MoveFirst
End Sub

Private Sub Command4_Click()
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
MsgBox "已经是第一条"
End If
End Sub

Private Sub Command5_Click()
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
MsgBox "已经是最后一条"
End If

End Sub

Private Sub Command6_Click()
Adodc1.Recordset.MoveLast
End Sub

Private Sub Command1_Click()
If Text14.Text <> "" Then
Adodc1.Recordset.Find "学号=" & Text14.Text & "", 0, adSearchForward, adBookmarkFirst

Else
MsgBox "条件不能为空,请输入查询条件!"
End If
Text14 = ""
Text14.SetFocus
End Sub

Private Sub Command2_Click()
End
End Sub
修改.查询.更新的程序
Dim xx As String

Private Sub Command1_Click()
Adodc2.Recordset.MoveFirst
'Adodc2.Recordset.MoveFirst
Adodc1.RecordSource = "select * from 学生与课程表 where 学号='" & Text1.Text & "'"
Adodc1.Refresh
End Sub

Private Sub Command10_Click()
Adodc1.Recordset.Fields("课程号") = DataCombo1.Text
Adodc1.Recordset.Fields("课程名称") = DataCombo2.Text
Adodc1.Recordset.Fields("学号") = Text1.Text
Adodc1.Recordset.Fields("成绩") = Text14.Text
Adodc1.Recordset.Fields("备注") = Text15.Text
Adodc1.Recordset.Update
End Sub

Private Sub Command11_Click()
Adodc1.Recordset.Delete
Adodc1.Recordset.Update
End Sub

Private Sub Command12_Click()
End
End Sub

Private Sub Command2_Click()
Adodc2.Recordset.MovePrevious
'Adodc2.Recordset.MovePrevious
If Adodc2.Recordset.BOF Then
Adodc2.Recordset.MoveFirst
MsgBox "已经到第一条!"
End If
Adodc1.RecordSource = "select * from 学生与课程表 where 学号='" & Text1.Text & "'"
Adodc1.Refresh
'If Adodc2.Recordset.BOF Then
'Adodc2.Recordset.MoveFirst
'MsgBox "已经到第一条!"
'End If
End Sub

Private Sub Command3_Click()
Adodc2.Recordset.MoveNext
'Adodc2.Recordset.MoveNext
If Adodc2.Recordset.EOF Then
Adodc2.Recordset.MoveLast
MsgBox "已经到最后一条!"
End If
Adodc1.RecordSource = "select * from 学生与课程表 where 学号='" & Text1.Text & "'"
Adodc1.Refresh
'If Adodc2.Recordset.EOF Then
'Adodc2.Recordset.MoveLast
'MsgBox "已经到最后一条!"
'End If
End Sub

Private Sub Command4_Click()
Adodc2.Recordset.MoveLast
'Adodc2.Recordset.MoveLast
Adodc1.RecordSource = "select * from 学生与课程表 where 学号='" & Text1.Text & "'"
Adodc1.Refresh
End Sub

Private Sub Command5_Click()
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Text10.Enabled = True
Text11.Enabled = True
Text12.Enabled = True
Text13.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
xx = Text1.Text
End Sub

Private Sub Command6_Click()
Adodc2.Recordset.Update
Adodc1.RecordSource = "select * from 学生与课程表 where 学号='" & xx & "'"
Adodc1.Recordset.Fields("学号") = Text1
Adodc1.Recordset.Update
Adodc1.RecordSource = "select * from 学生与课程表 where 学号='" & Text1 & "'"
MsgBox "修改成功!!"
Adodc1.Refresh
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
Text8.Enabled = False
Text9.Enabled = False
Text10.Enabled = False
Text11.Enabled = False
Text12.Enabled = False
Text13.Enabled = False

End Sub

Private Sub Command7_Click()
Adodc2.Recordset.CancelUpdate
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
Text8.Enabled = False
Text9.Enabled = False
Text10.Enabled = False
Text11.Enabled = False
Text12.Enabled = False
Text13.Enabled = False
End Sub

Private Sub Command8_Click()
Adodc2.Recordset.Delete
Adodc2.Recordset.MoveNext
If Adodc2.Recordset.EOF Then
Adodc2.Recordset.MoveLast
End If
End Sub

Private Sub Command9_Click()
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("课程号") = DataCombo1.Text
Adodc1.Recordset.Fields("课程名称") = DataCombo2.Text
Adodc1.Recordset.Fields("学号") = Text1.Text
Adodc1.Recordset.Fields("成绩") = Text14.Text
Adodc1.Recordset.Fields("备注") = Text15.Text
Adodc1.Recordset.Update
End Sub

Private Sub DataCombo1_Click(Area As Integer)
DataCombo2.Text = DataCombo1.BoundText
End Sub

Private Sub DataCombo2_Click(Area As Integer)
DataCombo1.Text = DataCombo2.BoundText
End Sub

Private Sub Form_Load()
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
Text8.Enabled = False
Text9.Enabled = False
Text10.Enabled = False
Text11.Enabled = False
Text12.Enabled = False
Text13.Enabled = False
Text14.Text = ""
Text15.Text = ""
DataCombo1.Text = ""
DataCombo2.Text = ""
Adodc1.RecordSource = "select * from 学生与课程表 where 学号='" & Trim$(Text1.Text) & "'"
Adodc1.Refresh
'Text14.Enabled = False
'Text15.Enabled = False
'Text16.Enabled = False
'Text17.Enabled = False
End Sub

Private Sub Text14_Change()
If Val(Trim$(Text14.Text)) < 60 Then
Text15.Text = "不及格"
Else
If Val(Trim$(Text14.Text)) >= 60 And Val(Trim$(Text14.Text)) < 70 Then
Text15.Text = "及格"
Else
If Val(Trim$(Text14.Text)) >= 70 And Val(Trim$(Text14.Text)) < 80 Then
Text15.Text = "及格"
Else
If Val(Trim$(Text14.Text)) >= 80 And Val(Trim$(Text14.Text)) < 90 Then
Text15.Text = "良好"
Else
If Val(Trim$(Text14.Text)) >= 90 Then
Text15.Text = "优异"
End If
End If
End If
End If
End If
End Sub
cang_2009
2010-01-05 · TA获得超过181个赞
知道小有建树答主
回答量:258
采纳率:0%
帮助的人:0
展开全部
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb;Persist Security Info=False" '设置数据库路径
Adodc1.CommandType = adCmdText '设置记录源
Adodc1.RecordSource = "select * from test" '连接数据库的test表文件
Set Text1.DataSource = Adodc1
Text1.DataField = "ID" '查询test表中的ID列,显示在Text1
End Sub
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zijinzhu
2010-01-05 · TA获得超过454个赞
知道小有建树答主
回答量:607
采纳率:0%
帮助的人:608万
展开全部
借用cang_2009
Adodc1.RecordSource ="SELECT * FROM MSysObjects WHERE ((Left([name],4)<>'MSys') AND ((MSysObjects.Type)=1)) ORDER BY MSysObjects.Name"
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式