Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
objConn.Open "Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=zhang;Initial Catalog=IPOPJ;Data Source=SV3\SQLEXPRESS"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = Date - 1
dtmEndDate.SetVarDate Date, True
dtmStartDate.SetVarDate DateToCheck, True
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Security' "_
& " And TimeWritten >= '" & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")
For each objEvent in colEvents
objRS.AddNew
objRS("Category") = objEvent.Category
objRS("ComputerName") = objEvent.ComputerName
objRS("EventCode") = objEvent.EventCode
objRS("Message") = objEvent.Message
objRS("RecordNumber") = objEvent.RecordNumber
objRS("SourceName") = objEvent.SourceName
objRS("TimeWritten") = objEvent.TimeWritten
objRS("Type") = objEvent.Type
objRS("UserName") = objEvent.User
objRS.Update
Next
objRS.Close
objConn.Close
关键词标签:windows,事件日志,sql
相关阅读
热门文章 windows7虚拟光驱安装和使用方法解决应用程序正常初始化(0xc0000135)失败hosts文件位置以及如何修改hosts文件[声音故障]XP没有声音,丢失Windows Audi
人气排行 [声音故障]XP没有声音,丢失Windows Audio服务(AudioSrv)[警解决Windows 7黑屏的有效方法windows2003中关于软路由设置方法的具体介绍Windows不能在本地计算机启动OracleDBConsoleorcl一个空文件夹删不掉的解决办法Windows 7加XP的局域网搭建与文件共享用Windows命令行实现自动SSH代理Windows提示错误应用程序update.exe
查看所有0条评论>>