vb6.0查询ACCESS

来源:百度知道 编辑:UC知道 时间:2024/05/24 23:34:52
现有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

请参阅:
http://iask.sina.com.cn/b/5963519.html
zhudingyun808的答复.

如果你要找num=1的纪录就用
select * from list where num='1'