dim ac_tmp as new adodb.connection
dim ar_tmp as new adodb.recordset
With ac '数据库连接
If .State = adStateOpen Then .Close
.ConnectionString = "driver=SQL Server;server=" & 计算机名或IP地址& ";uid=sa;pwd=;database=" & 数据库名称
.CommandTimeout = 120
.Open
End With
if ar_tmp.state=adstateopen then ar_tmp.close
'打开数据表
ar_tmp.open "select * from tablename ",ac_tmp,adopenkeyset,adlockreadonly
set mshflexgrid.datasource=ar_tmp
set ar_tmp=nothing '销毁对象
set ac_tmp=nothing