How to monitor SQL sent to server

Posted on 2007-07-20
Last Modified: 2013-11-26
I'm having a problem with a Gridview's update statement in VS2005/Postgress SQL server. On testing this on my local PC running VS2005, and hitting a Postgres SQL server on a differnt box.  I'm trying to find a way to monitor the SQL that is sent to the server, as I'm doing something wrong. With MS SQL Server, I have SQL Profiler. But I don't think any such tool exist with Postgres.

Any suggestions in VS2005 on how to capture this? Any tool recommend to work with Postgres?

We are using corelab's .net drivers for Postgres.

On my DEV PC I'm trying to run their DBmonitor. I'm trying to find all the documentation for this. I've been working with this: ms-help://MS.VSCC.v80/CoreLab.PostgreSql/PgSQLDirect/DbMonitor.html

Since this is an page, there is no form to drop the control into per the instructions. I click on VS2005/view/compnent designer and I can drag the compoent onto the dark grey page which in turn places the code in the aspx.vb page. I see the option to Set PgSqlMonitor.IsActive. I activate the DBmonitor app, I then run the web page and get nothing in DBmonitor.

So I move onto the second half of the directions below: Using DBMonitor with ASP.NET projects

However, I don't have the processtag in my machine.config file.
Question by:Thirt
    LVL 10

    Accepted Solution


    My idea would be to monitor this at the PostgreSQL sever (of course if you have access) using the log:
    log_statement (string)
    Controls which SQL statements are logged. Valid values are none, ddl, mod, and all. ddl logs all data definition statements, such as CREATE, ALTER, and DROP statements. mod logs all ddl statements, plus data-modifying statements such as INSERT, UPDATE, DELETE, TRUNCATE, and COPY FROM. PREPARE, EXECUTE, and EXPLAIN ANALYZE statements are also logged if their contained command is of an appropriate type. For clients using extended query protocol, logging occurs when an Execute message is received, and values of the Bind parameters are included (with any embedded single-quote marks doubled).

    Read more here:

    LVL 15

    Expert Comment

    If you are using PostgeSQL ODBC drivers (pgODBC), one of the options there is logging all queries to a local file. You can look it up by setting up a file DSN with that checkbox checked, then looking at the content of that file. The option is somewhere under "advanced", 2nd page.
    LVL 4

    Author Comment

    Thanks for the replies. But I'm using a .net driver, not ODBC. And Adpro's solution worked perfectly.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now