I agree with @StriplingWarrior, using vendor factories will make your code drier and follow best practices. DbProviderFactories really the best way to do this, and your code will obviously not rely on Glimpse.
However, if you really want to just upgrade with your existing application code, Glimpse will support you with the following changes:
using (var conn = new GlimpseDbConnection(new SqlConnection(cString)) { conn.Open(); DbCommand cmd = conn.CreateCommand(); cmd.CommandText = "Select count(*) from table"; cmd.CommandType = CommandType.Text; txtResult2.Text = cmd.ExecuteScalar().ToString(); conn.Close(); }
In the above example, a command is created using the CreateCommand() method, which eliminates the need to bind the command and connection.
Alternatively, you can also explicitly create a command as follows:
conn.Open(); DbCommand cmd = new GlimpseDbCommand(new SqlCommand()); cmd.Connection = conn; cmd.CommandText = "Select count(*) from table"; cmd.CommandType = CommandType.Text;
Finally, more documentation on the SQL tab can be obtained by clicking the ? in the Glimpse user interface when you select a tab, or by going to our SQL documentation on getGlimpse.com . ( I will add this information to this page for future reference. )
nikmd23
source share