B
Big Daddy
Let's say I have some code like this:
try
{
using (SqlConnection conn = new SqlConnection(strConnect))
using (SqlCommand cmd = new SqlCommand("", conn))
{
conn.Open();
cmd.CommandText = "select * from SomeTable";
cmd.ExecuteScalar();
}
}
catch (SqlException ex)
{
// Do logging
}
In my exception handler, when I'm trying to log the error, I'd like to
be able to get the command text that caused the exception to be thrown
(in the example above, it would be "select * from SomeTable"). The
SqlException class has a collection of SqlErrors, but they don't
appear to have the text I want. Is there a way for me to get this?
thanks in advance,
John
try
{
using (SqlConnection conn = new SqlConnection(strConnect))
using (SqlCommand cmd = new SqlCommand("", conn))
{
conn.Open();
cmd.CommandText = "select * from SomeTable";
cmd.ExecuteScalar();
}
}
catch (SqlException ex)
{
// Do logging
}
In my exception handler, when I'm trying to log the error, I'd like to
be able to get the command text that caused the exception to be thrown
(in the example above, it would be "select * from SomeTable"). The
SqlException class has a collection of SqlErrors, but they don't
appear to have the text I want. Is there a way for me to get this?
thanks in advance,
John