用vb的ado数据库访问组件 与系统odbc建立数据源连接
然后从ado的组件设置的access数据库中访问需要读取字段的表table1
然后用ado组件执行sql语句"select num from table1"
然后将其赋值给str
Dim DB As Database
Set DB = OpenDatabase("d:\school\xsmd.mdb")
Dim select_db As Recordset
Set select_db = DB.OpenRecordset("select * from table1 where number='2001'", dbOpenDynaset)
If select_db.RecordCount >= 1 Then
Dim str As String
str = select_db.Fields("name")
Print str
End If
工程中必须添加引用:microsoft DAO 3.6