Re: Interesting Problem regarding Parameters

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Sorry for the double post.

Carlo,

"Carlo Razzeto" <crazzeto@xxxxxxxxxxx> wrote in message
news:Oh8WkaElFHA.2152@xxxxxxxxxxxxxxxxxxxxxxx
> Backgroud:
> My company is currently migrating to .Net from PHP for a number of
> reasons, however we have one slight problem we would very much like to
> solve before moving to .Net (ok, many but this one is a toughie).
>
> Problem:
> On our current PHP platform we have our own database abstraction class
> which inherits from the PEAR DB abstraction class. One of the major
> reasons why we did this is because we wanted to add automatic querie
> logging to our database connection object. Here is a brief snippit of code
> to demonstarte the functionality we currently have:
>
> //Creating DB connection objects
> $connection = mis_DB::connect( 'database-server', 'database' );
> $connection->addLog( 'file', '/log_path/filename.log', PEAR_LOG_MODE );
> $connection->setLogMask( MISDB_LOG_ALL );
>
> This will automatically log any queries thrown at at, for example (I'm
> using prepare and execute syntax for a reason that will be come clear in
> just a minute):
>
> /* Disclaimer, such a DB does not exist on my company DB server, but it
> should! */
> $query = "SELECT * FROM beer.beer_styles WHERE style = ?";
> $handle = $connection->prepare( $query );
> $result_object = $connection->execute( $handle, array( "Imperial
> Stout" ) );
>
> What our current database class will do (after executing the query) is
> logg the following message to the /log_path/filename.log file:
> Friday, July 29, 2005 8:41:10 AM [Informational] SELECT * FROM
> beer.beer_styles WHERE style = 'Imerial Stout'
>
> What we would like is to have some thing similar with our new .Net DB
> class, however the problem I'm running into is I don't know how to get the
> query that was actually executed on the server, what I mean by that is:
>
> //Assume I have a proper connection string
> OleDbConnection Connection = new OleDbConnection( ConnectionString );
> OleDbCommand Command = new OleDbCommand( "", Connection );
> Connection.Open();
>
> //Set the query with parmater then execute reader
> Command.CommandText = "SELECT * FROM beer.beer_styles WHERE style =
> @style";
> Command.Paramaters.Add( "@style", "Imperial Stout" );
> OleDbDataReader Reader = Command.ExecuteReader();
>
> How do I get the query that actually executed on our DB server, i.e.
> "SELECT * FROM beer.beer_styles WHERE style = 'Imperial Stout'", not
> "SELECT * FROM beer.beer_styles WHERE style = @style".
>
> Thanks for the help!
>
> ----------------------
> Carlo Razzeto
> carlo.razzeto@xxxxxxxxxxx
>


.



Relevant Pages

  • Interesting Problem regarding Parameters
    ... My company is currently migrating to .Net from PHP for a number of reasons, ... database connection object. ... What our current database class will do (after executing the query) is logg ... //Set the query with parmater then execute reader ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: PEAR MDB2 Unknown Error
    ... I'm bumping into an issue with my installation of the MDB2 package ... I'm trying to execute a query, ... is created in the parent class' constructor and a connection *is* ... I just can't seem to query against it. ...
    (comp.lang.php)
  • Re: Interesting Problem regarding Parameters
    ... One of the major reasons why ... > database connection object. ... > however the problem I'm running into is I don't know how to get the query ... > OleDbConnection Connection = new OleDbConnection; ...
    (microsoft.public.dotnet.framework.adonet)
  • Interesting Problem regarding Parameters
    ... My company is currently migrating to .Net from PHP for a number of reasons, ... database connection object. ... prepare and execute syntax for a reason that will be come clear in just a ... OleDbConnection Connection = new OleDbConnection; ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: stored proc ansi_nulls help
    ... on connection which execute your SP. ... > Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. ... Enable these options and then reissue your query. ... > I put the ansi nulls and ansi warnings in when building the proc but am still recieving the error. ...
    (microsoft.public.sqlserver.programming)