千千

IT博客 首页 新随笔 联系 管理
  16 Posts :: 24 Stories :: 5 Comments :: 0 Trackbacks
vb6.0查询ACCESS
解决时间:2007-1-7 22:01
现有ACCESS2000数据库文件tel.mdb,内有一表list,其中有字段id、num、area、t。现在通过 num 查询 area。用VB6.0怎么实现。
 
----------------------------------------------------------------------------------------------
用Text1做查询输入,这里num属数值字段,用Adodc1控件连接数据库,用
DataGrid1做显示查询结果,在DataGrid1的属性页中选其DataSource为Adodc1.如果num字段为文本,则将sql句改为:
sql = "select area from list where num ='" & Val(Text1) & "'"

Private Sub Command1_Click()
sql = "select area from list where num =" & Val(Text1)
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\te1.mdb;Persist Security Info=False"
Adodc1.RecordSource = sql
Adodc1.Refresh'对查询更新
DataGrid1.Refresh
End Sub
posted on 2007-01-21 17:39 千千 阅读(451) 评论(0)  编辑 收藏 引用 所属分类: VB
只有注册用户登录后才能发表评论。