Using parameters: Get SQL sent to database

C

Cor Ligthert [MVP]

Sorry

And in that the datetime and smalldatetime at the left side, this part from
MSDN doesn't return a good link

Cor
 
A

Armin Zingler

Cor Ligthert said:
Armin,

From the Jet engine of Access you find almost nothing about this on
MSDN, I asked you in this message thread if you even knew the
internal format that Access uses and you did not reply that to me..

Sorry Cor, where? Which internal format? I don't care about the internal
format. This thread is about getting the SQL.

Sorry again, these are Tsql keywords I don't know what you are trying to
tell me. As I wrote, I'm using Access.

Sorry once more, I can only repeat myself if I write more.


Armin
 
L

luxspes

luxspes said:
Armin Zingler wrote:

(A Gentle Introduction to ADO.NET 2.0 Trace Facilities):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/tracingdataaccess.asp


Copy&Pasted from (A Gentle Introduction to ADO.NET 2.0 Trace Facilities):

Using Tracing to Debug a Parameter Binding Problem

Now that we've gone through the quick overview of tracing, I'd like to
present a simple use case. I'd often use ODBC trace to do problem
determination when an application would "eat" a rich error message and
produce a polite but fairly "information-free" message. Such application
code would look like this:

string s = GetConnectionStringFromConfigFile();
using (SqlConnection conn = new SqlConnection(s))
using (SqlCommand cmd = new SqlCommand(
"select * from authors where au_id = @auid", conn))
{
// the error is hardcoded here but could have come from suboptimal
// editing in a graphic user interface
cmd.Parameters.Add("@auid", SqlDbType.Int);
cmd.Parameters[0].Value = 123456789;
SqlDataReader rdr = null;
try {
// some code that could fail goes here
conn.Open();
rdr = cmd.ExecuteReader();
while (rdr.Read())
Console.WriteLine(rdr[0]);
rdr.Close();
}
catch (Exception e) {
MessageBox.Show("polite error message");
}
}

In this case, the error was caused by a parameter type mismatch, and the
person diagnosing the error might not have access to the source code of
the program. Turning on the trace, we'll see output like this:

"enter_01 <sc.SqlCommand.ExecuteReader|API> 1#"
"<sc.SqlCommand.get_Connection|API> 1#"
"<sc.SqlCommand.get_Connection|API> 1#"
"<sc.TdsParser.CreateSession|ADV> 1# created session 3"
"<sc.TdsParserSessionPool.CreateSession|ADV> 1# adding session 3 to pool"
"<sc.TdsParserSessionPool.GetSession|ADV> 1# using session 3"
"<sc.TdsParser.GetSession|ADV> 1# getting session 3 from pool"
"<sc.SqlCommand.ExecuteReader|INFO> 1# Command executed as RPC."
"<sc.SqlCommand.get_Connection|API> 1#"
"leave_01"
"enter_01 <sc.SqlDataReader.Read|API> 1#"
"<sc.SqlError.SqlError|ERR> infoNumber=245 errorState=1 errorClass=16
errorMessage='Syntax error converting the varchar value '172-32-1176' to a
column of data type int.' procedure='' lineNumber=1"
"leave_01"

This shows us directly that there is a parameter value mismatch. The
sample and the trace file are provided in the article code. Note that
the trace file is much more compact in this case because we're only
tracing with the System.Data.1 provider.
 
C

Cor Ligthert [MVP]

Armin,
Sorry Cor, where? Which internal format? I don't care about the internal
format. This thread is about getting the SQL.

If Jet can not store milliseconds, that it is not important how you will get
that in a SQL string or whatever, I am myself interested if Access can do
that.

If it can do that, than the change that it divers in the SQL string with the
way it is done in Access in SQL server is mostly in this kind of
instructions.

It sound for me if you now are asking "I am using Access, what operator do
I have to use to add".

This are the pages about SQL and specific Jet Access.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acfundsql.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acintsql.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acadvsql.asp

Sorry if this is not clear.

Cor
 
C

Cor Ligthert [MVP]

Luxspes,

I gave the link to your message to Rene already to Armin, I had never seen
this question and now almost exatly the same in one day (accoording to time
zones probably)

:)

Cor
 
A

Armin Zingler

Cor Ligthert said:
Armin,


If Jet can not store milliseconds, that it is not important how you
will get that in a SQL string or whatever,

It can, otherwise I would not have asked how to store them. I already wrote
that inserting records with parts of a second into the database using
parameters works without a problem.

You didn't answer where you asked for this, but never mind.
I am myself interested if
Access can do that.

It can.
If it can do that, than the change that it divers in the SQL string
with the way it is done in Access in SQL server is mostly in this
kind of
instructions.

It sound for me if you now are asking "I am using Access, what
operator do I have to use to add".

This are the pages about SQL and specific Jet Access.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acfundsql.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acintsql.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acadvsql.asp

Sorry if this is not clear.

I don't know what you're talking about, but thanks for the links....

For me is EOT here.


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top