1、工程>引用,选micfosoft AxtiveX data objects 2.*
2、建连接字符串
Public Const linkcn As String = " Provider=sqloledb;Data Source=机器名;Initial Catalog=数据库名;User Id=sa;Password= sa"
3、用ado对象
Dim cnGet As ADODB.Connection
cnGet.Open linkcn
Dim rsGet As ADODB.Recordset
Set rsGet = New ADODB.Recordset
sSql="select * from 表"
rsGet.Open sSql, cnGet, adOpenStatic, adLockReadOnly