Function cnn() As ADODB.Connection
'定义数据库连接函数 Set cnn = New ADODB.Connection' 返回一个数据库连接
cnn.Open "Driver={SQL Server};Server=(local);Database=数据库名称;Uid=用户;Pwd=密码" End Function
'模块声明Dim withevents adoPrimaryRS As RecordsetPublic Function Fac(db as connection)Set db=New Connection'创建连接对象实例db.CursorLocation=aduseClient'游标类型为客户端游标db.open"PROVIDER=SQLOLE