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