William \(Bill\) Vaughn
6/29/2007 5:45:00 PM
I understand completely. We've been trying to get MS to divulge the error
numbers (like we had back in VB6) for some time now. The problem with the
exceptions is that they are often too generic ("Something happened") and the
messages don't really help an end user any more than a fist-full of
documentation. As it is the messages are often less than useful--sometimes
pointing blame at conditions that don't exist and are way beyond the control
of the end user.
I'm sure you understand it's not the end-user that needs to debug the
connection issue--it's your application. None of the messages returned by
the Framework are suitable for end-user consumption. They are the person
with the least chance of fixing the problem. Without an in-depth
understanding of the exceptions and the information they return you're
running blind. In addition, if you write code to test for a specific
exception message, you're pooched when the application has to be ported to
another language (English to French, or English to Texan).
I applaud your efforts to bring sanity to the handling of exceptions. I
might suggest that you look at the Exception Handler Blocks that might
clarify some of this for you (and everyone else).
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
"Henrik Skak Pedersen" <skak@community.nospam> wrote in message
news:%23mjIyOcuHHA.736@TK2MSFTNGP06.phx.gbl...
> Hi Wen,
>
> Thank you for your reply.
>
> I would just like to show a decent error messsage to the user if something
> goes wrong during the connection phase.
>
> Cheers
> Henrik.
>
> "WenYuan Wang [MSFT]" <v-wywang@online.microsoft.com> wrote in message
> news:eaXOOTNtHHA.2312@TK2MSFTNGHUB02.phx.gbl...
>> Hi Henrik,
>> Thanks for your waiting.
>>
>> I have spend the whole day searching on internet and documents, however,
>> doesn't found List which included all possible error number caused by
>> Open()/Execute***(). I also tried with Reflector. This doesn't help...
>>
>> Sorry, for my curious, would you please kindly let me know why do you
>> want
>> to get such Error Number list? If you just want to write some
>> trouble-shooting document for your end user, I think the information in
>> SQLException.error is enough.
>>
>> For the entire error messages, I'm afraid the only way is that querying
>> the
>> sys.messages system table for the message_id and text of SQL Server
>> errors.
>> See the error messages topic in SQL Books Online. On the client side, see
>> the documentation in the .NET Framework Help for these classes:
>> SqlConnection.Open, SqlException, and SqlErrorCollection/SqlError, which
>> enables you to handle server-side errors. However, there must be a lot of
>> work for us.
>>
>> I'm sorry if you feel this isn't really helping...
>> But, would you please let us know what your objective is? Maybe there is
>> other way to approach that without the Erro Number List...
>>
>> Thanks again for your patience
>> Sincerely,
>> Wen Yuan
>> Microsoft Online Community Support
>> ==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>
>