国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 数据库 > access > 如何确定有多少人登陆数据库?

如何确定有多少人登陆数据库?

来源:程序员人生   发布时间:2014-02-03 03:51:21 阅读次数:3308次

Sub?ShowUserRosterMultipleUsers()
????Dim?cn?As?New?ADODB.Connection
????Dim?cn2?As?New?ADODB.Connection
????Dim?rs?As?New?ADODB.Recordset
????Dim?i,?j?As?Long

????cn.Provider?=?"Microsoft.Jet.OLEDB.4.0"
????cn.Open?"Data?Source=c:Northwind.mdb"

????cn2.Open?"Provider=Microsoft.Jet.OLEDB.4.0;"?_
????&?"Data?Source=c:Northwind.mdb"

????'?The?user?roster?is?exposed?as?a?provider-specific?schema?rowset
????'?in?the?Jet?4?OLE?DB?provider.??You?have?to?use?a?GUID?to
????'?reference?the?schema,?as?provider-specific?schemas?are?not
????'?listed?in?ADO's?type?library?for?schema?rowsets

????Set?rs?=?cn.OpenSchema(adSchemaProviderSpecific,?_
????,?"{947bb102-5d43-11d1-bdbf-00c04fb92675}")

????'Output?the?list?of?all?users?in?the?current?database.

????Debug.Print?rs.Fields(0).Name,?"",?rs.Fields(1).Name,?_
????"",?rs.Fields(2).Name,?rs.Fields(3).Name

????While?Not?rs.EOF
????????Debug.Print?rs.Fields(0),?rs.Fields(1),?_
????????rs.Fields(2),?rs.Fields(3)
????????rs.MoveNext
????Wend

End?Sub

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生