在VB中ADODC控件怎么用???

来源:百度知道 编辑:UC知道 时间:2024/05/13 05:53:46
我用VB做图书馆图书管理程序,问一下用ADODC控件怎么才可以查找图书呢~??
查找代码是什么呢(按 图书名称查找)。。。。。。
回答者:掌柜的来两盅 的答案可以用,还有个问题就是如果没有那要查的那条记录就让它Msgbox "没有找到此记录"怎么实现????

adodc1.recordset.find("name='" & text1.text & "'")

是ADODB好不好?

Private Sub Form_Load()
Text1 = ""
With Adodc1
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\db1.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select name from b1 order by name"
Adodc1.Refresh
DataGrid1.Refresh
End With
End Sub

Private Sub Text1_Change()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\db1.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select name from b1 where name >='" & Text1 & "' order by name"
Adodc1.Refresh'对查询更新
DataGrid1.Refresh
End Sub
具体做法:
新建工程时选数据工程,此时VB6集成调试环境左边工具箱内已加载了有关数据库编程必须的控件。
然后在FORM1窗体中添加ADODC控件和DATAGRID控件,将DATAGRID1的属性DATASOURCE选ADODC1,打开ADODC1控件属性页使用连接字符串,选生成,在提供者选项中选MICROSOFT jet 4.0 OLE DB Provider