您现在的位置是:网站首页> 数据库
MS SQL2008R2 监控
- 数据库
- 2022-02-07
- 755人已阅读
使用X86
引用C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies
下的
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.ConnectionInfoExtended.dll
代码
try
{
ConnectionInfoBase conninfo = new SqlConnectionInfo();
((SqlConnectionInfo)conninfo).ServerName = "XN_PCWindow";
((SqlConnectionInfo)conninfo).UserName = "xn";
((SqlConnectionInfo)conninfo).Password = "123abc";
((SqlConnectionInfo)conninfo).DatabaseName = "xysys";
((SqlConnectionInfo)conninfo).UseIntegratedSecurity = true;
TraceServer trace = new TraceServer();
trace.InitializeAsReader(conninfo, "look.tdf");
while (trace.Read())
{
//Statements;
Console.WriteLine(trace["TextData"]);
}
Console.Read();
trace.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
创建模板文件
列筛选器
点击“TextData”,输入2列值,比如我们现在只监视插入语句和更新语句,就输入%insert%,回车。再第二行输入“%update%”
导出look.tdf