|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to read commandtext after added parameters?If I construct a new Select command I use parameters to fill in the data i want to query for. Sometimes I make mistakes and I would then like to check the text directly on the sql server. Before I started using parameters I could just copy the commandtext to the server and see what happens, but if I do that now, I see the parameters, not their values. How can I see the commandtext as it is executed by the server? i.e. mycmd = new commandtext("Select * from Table1 Where user = @user",connection") mycmd.parameters.add("@user",varchar,25).value = "myself" I would like to see: "Select * from Table1 Where user = 'myself'" Is this possible? rg. Eric Am 24.03.2010 12:52, schrieb Eric:
> Hi, A very good question that I've also asked some years ago. (and in advance:> > If I construct a new Select command I use parameters to fill in the data i > want to query for. > > Sometimes I make mistakes and I would then like to check the text directly > on the sql server. Before I started using parameters I could just copy the > commandtext to the server and see what happens, but if I do that now, I see > the parameters, not their values. > > How can I see the commandtext as it is executed by the server? I still don't have a solution) I couldn't imagine that I, as a programmer, am not able to see the SQL I'm sending myself to the database. For example, I wanted to log them in a file. Logging the parameterized query and the parameters seperately was and is not satisfying. In addition, I was trying to quickly find out the format of some values (date format etc) so that I could use it in queries inside Sql Server Management Studio, probably just like you. I was told to enable SQL logging in the DBMS. I still think this is looking at the wrong end, but once again I seemed to be the only one that complained - til now. ;) -- Armin "Armin Zingler" <az.nospam@freenet.de> wrote in message <snip>news:OaXwJw0yKHA.2644@TK2MSFTNGP04.phx.gbl... > Am 24.03.2010 12:52, schrieb Eric: Show quoteHide quote >> How can I see the commandtext as it is executed by the server? I think part of the problem is that the provider can decide to use > > A very good question that I've also asked some years ago. (and in > advance: > I still don't have a solution) I couldn't imagine that I, as a > programmer, > am not able to see the SQL I'm sending myself to the database. For > example, > I wanted to log them in a file. Logging the parameterized query and > the > parameters seperately was and is not satisfying. In addition, I was > trying > to quickly find out the format of some values (date format etc) so > that > I could use it in queries inside Sql Server Management Studio, > probably > just like you. > > I was told to enable SQL logging in the DBMS. I still think this is > looking > at the wrong end, but once again I seemed to be the only one that > complained > - til now. ;) parameterisation to pass the base query once and then pass just the parameters to the DBMS for each query. What we want is a "debug mode" for the provider (or a different provider) that does just pass unparameterised SQL each time, and then it might as well make the final SQL available through a read only parameter. -- Regards, Mark Hurd, B.Sc.(Ma.) (Hons.) Eric,
Why inventing that wheel again with squares instead of a rounds. In my gives SQL profiler you back all the information you ask about? http://msdn.microsoft.com/en-us/library/ms187929.aspx Cor Show quoteHide quote "Eric" <E***@discussions.microsoft.com> wrote in message news:9CCB41F7-85DD-4E83-BD11-FCB445BADE3F@microsoft.com... > Hi, > > If I construct a new Select command I use parameters to fill in the data i > want to query for. > > Sometimes I make mistakes and I would then like to check the text directly > on the sql server. Before I started using parameters I could just copy the > commandtext to the server and see what happens, but if I do that now, I > see > the parameters, not their values. > > How can I see the commandtext as it is executed by the server? > > i.e. > > mycmd = new commandtext("Select * from Table1 Where user = > @user",connection") > mycmd.parameters.add("@user",varchar,25).value = "myself" > > I would like to see: "Select * from Table1 Where user = 'myself'" > > Is this possible? > > rg. > Eric > Am 29.03.2010 09:46, schrieb Cor Ligthert[MVP]:
> Eric, How to determine the SQL I send to an Access database?> > Why inventing that wheel again with squares instead of a rounds. > > In my gives SQL profiler you back all the information you ask about? > > http://msdn.microsoft.com/en-us/library/ms187929.aspx I send it but I don't know what I send. -- Armin Armin,
I expected this answer, but I've read first what the OP sent. (I had almost connected my answer to your reply :-) ) > Sometimes I make mistakes and I would then like to check the text directly Is it really to expect that this is needed for an Jet database engine?> on the sql server. But nobody prevents you to get the Command.Text and replace the OleDB parameters which are then unnamed (and in fact ?) that yourself. I'm sure you know how to do that? :-) CorShow quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:e9wH5LzzKHA.4328@TK2MSFTNGP04.phx.gbl... > Am 29.03.2010 09:46, schrieb Cor Ligthert[MVP]: >> Eric, >> >> Why inventing that wheel again with squares instead of a rounds. >> >> In my gives SQL profiler you back all the information you ask about? >> >> http://msdn.microsoft.com/en-us/library/ms187929.aspx > > How to determine the SQL I send to an Access database? > I send it but I don't know what I send. > > -- > Armin Am 29.03.2010 13:50, schrieb Cor Ligthert[MVP]:
> Armin, I have no doubts. :)> > I expected this answer, but I've read first what the OP sent. >> Sometimes I make mistakes and I would then like to check the text directly Yes, I needed it.>> on the sql server. > > Is it really to expect that this is needed for an Jet database engine? > But nobody prevents you to get the Command.Text and replace the OleDB Even if I know how to do it, the String that I build is not the String> parameters which are then unnamed (and in fact ?) that yourself. > > I'm sure you know how to do that? > > :-) that is sent to the database (engine). The latter is what I want to see. And if I already build the string myself, I could send it to the database instead of using the Parameters property, but isn't the latter recommended? -- Armin Armin,
I am not so sure that a complete string is sent, the command procedure is the same as with a stored procedure, where the mechanism of the parameters is used. http://msdn.microsoft.com/en-us/library/ms378675.aspx Cor Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:uJBQR20zKHA.4492@TK2MSFTNGP05.phx.gbl... > Am 29.03.2010 13:50, schrieb Cor Ligthert[MVP]: >> Armin, >> >> I expected this answer, but I've read first what the OP sent. > > I have no doubts. :) > >>> Sometimes I make mistakes and I would then like to check the text >>> directly >>> on the sql server. >> >> Is it really to expect that this is needed for an Jet database engine? > > Yes, I needed it. > >> But nobody prevents you to get the Command.Text and replace the OleDB >> parameters which are then unnamed (and in fact ?) that yourself. >> >> I'm sure you know how to do that? >> >> :-) > > Even if I know how to do it, the String that I build is not the String > that is sent to the database (engine). The latter is what I want to see. > And if I already build the string myself, I could send it to the database > instead of using the Parameters property, but isn't the latter > recommended? > > -- > Armin |
|||||||||||||||||||||||