vb 用adodc控件查询和修改access数据库中的表信息
3个回答
展开全部
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
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
展开全部
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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
借用cang_2009
Adodc1.RecordSource ="SELECT * FROM MSysObjects WHERE ((Left([name],4)<>'MSys') AND ((MSysObjects.Type)=1)) ORDER BY MSysObjects.Name"
Adodc1.RecordSource ="SELECT * FROM MSysObjects WHERE ((Left([name],4)<>'MSys') AND ((MSysObjects.Type)=1)) ORDER BY MSysObjects.Name"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询