Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Profiling ADO.NET calls - Connection String , Command and Execution Time

$
0
0

Hi,

I am researching on profiling .NET web applications using IL rewriting.

I am injecting the C# function call(resides in assembly) to the functions in running web application before the JIT compilation is done (in profiler's JITCompilationStarted callback function). While the changed IL function body gets executed and when that injected function is getting called I m logging the necessary data.

Now when the web applications executes some DB calls using any Database providers , i need to profile their DB connection and the queries that are executed.

For those ORM's that uses DbProviderFactor to access database , i proxied the DbProviderFactory Class and overridden the "Assembly Qualified name" with my class name. So here i can get the connection and command name and everything is fine now.

The problem comes for raw ADO.NET calls as used in the code below.

SqlConnection myConn = new SqlConnection(@"Server=192.168.23.99;Initial Catalog=cat1;User ID=user21;Password=userpwd");
SqlCommand myCommand = new SqlCommand("select * from table1", myConn);
SqlDataReader dataReader;

myConn.Open();
dataReader = myCommand.ExecuteReader();

GridView1.DataSource = dataReader;
GridView1.DataBind();
dataReader.Close();
myCommand.Dispose();
myConn.Close();

Obviously calls will not go through my proxied DbProviderFactory Class. So how can i get the Connection and command text when such direct ADO.NET calls are used,??

I m not able to get a clear documentation on this part.

(Please let me know if i m not clear with the problem). 



Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>