Hey everyone I wanted to post some code I had sometime back when on how I pulled SQL stats from a SQL Server using VB.NET and ASP.NET. The code that will be in this post is actually part of a class that handles the SQL stats, but you can incorporate it however you would like. There are a few things required for this.
1. This is written in .NET 2.0
2. You need to add Imports System.Diagnostics to your class or aspx page
3. You also have to have the rights to pull system stats from your SQL Server. What this means is that you either need to enable Indentity Impersonate on the web application and make sure whoever uses the app has rights, or run the web application under an Application Pool in IIS that has access to the SQL Servers.
4. You'll see a variable in this class Me._Server. Replace this with the server name you are trying to pull stats from or create a variable names _Server as a String
5. Add a reference to the COM object Microsoft SQLDMO Object Library
Ok so here is some code that should get you by for a simple SQL Monitoring tool. Again you can use this wherever you want in your app. I had mine in a seperate class.
Again hope this helps those that need to gather sql stats in a quick manner or need to monitor a sql server for stat purposes / high overview of usage.
0c577b5c-c734-45c4-8fe7-638eb2371fa7|0|.0
ASP.NET, Microsoft SQL
sql, asp.net