SQLException - message property was empty

  • Thread starter Thread starter QC
  • Start date Start date
Q

QC

Hi Friends,

When calling SqlCommand.ExecuteNonQuery() method, i got SQLException.
But the surprise thing is, the message property was empty. Could any
one provide some input about what went wrong and why the property
value was empty?

Thanks in advance...
 
QC explained :
Hi Friends,

When calling SqlCommand.ExecuteNonQuery() method, i got SQLException.
But the surprise thing is, the message property was empty. Could any
one provide some input about what went wrong and why the property
value was empty?

Thanks in advance...

What about the other properties of that exception, especially the
Errors collection?

Hans Kesting
 
QC explained :




What about the other properties of that exception, especially the
Errors collection?

Hans Kesting

i am not so clear about other properties, because in our system we
normally log the string returned from SQLException.ToString(). hence,
i do not have steps to reproduce this error again.

This is the string i got from SQLException.ToString():

System.Data.SqlClient.SqlException:

at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
 
Hi Friends,

When calling SqlCommand.ExecuteNonQuery() method, i got SQLException.
But the surprise thing is, the message property was empty. Could any
one provide some input about what went wrong and why the property
value was empty?

Thanks in advance...

I had never seen a SQL exception without a message.

Did you check InnerException?
 
i am not so clear about other properties, because in our system we
normally log the string returned from SQLException.ToString(). hence,
i do not have steps to reproduce this error again.

This is the string i got from SQLException.ToString():

System.Data.SqlClient.SqlException:

   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

Hi,

Youi should also log StackTrace & check the InnerException property.
This apply to ALL types of exceptions.
 
There information were logged into the log file using
SQLException.ToString(). as i had said, i don’t have proper steps to
reproduce it, hence i could not see the InnerException property.
 
Back
Top