Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15987

Re: Handling ODBC Connection Errors

Newsgroups comp.lang.javascript
Date 2012-09-18 23:19 -0700
References <87t1585mmsdg8bqdd8vblsch7esmc36iu2@4ax.com> <70h258trauptcfp6vm5jp5i96h6tonm5pv@4ax.com>
Message-ID <b5199f42-1a4f-4178-801e-cb425caca6ce@googlegroups.com> (permalink)
Subject Re: Handling ODBC Connection Errors
From David Mark <dmark.cinsoft@gmail.com>

Show all headers | View raw


On Wednesday, September 12, 2012 10:33:00 PM UTC-4, Gene Wirchenko wrote:
> On Wed, 12 Sep 2012 14:03:26 -0700, Gene Wirchenko <genew@ocis.net>
> 
> wrote:
> 
> 
> 
> >Dear JavaScripters:
> 
> >
> 
> >     Well, I am connecting to SQL Server.  Now, I am trying to handle
> 
> >the errors that can happen.
> 
> >
> 
> >     Please note that this is checkout work for what will eventually
> 
> >be server-side code.  The argument that one should not use direct
> 
> >access to the DBMS in browser code does not apply here.
> 
> >
> 
> >     If I do not use try-catch and there is an error in my connection,
> 
> >my program abends with an error.  Naturally, I want to trap any such
> 
> >error.  I can do that, but I do not get much information.  Catching to
> 
> >e gets me an e.name of "Error" and an e.message such as:
> 
> >          [Microsoft][ODBC SQL Server Driver][SQL Server]Error
> 
> >converting data type varchar to date.
> 
> >or (note the variable text):
> 
> >          [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or
> 
> >function 'GetPriRow' expects parameter '@theKey', which was not
> 
> >supplied.
> 
> >
> 
> >     This is not too terribly usable.  Is there a way to get the
> 
> >information broken down?  Even just an error number distinguishing the
> 
> >error messages would be nice.
> 
> >
> 
> >     Note that the various errors are not the point; being able to
> 
> >identify so as to possibly handle each error is.
> 
> 
> 
>      OK, I did find that .number can be used.  (I so dislike
> 
> inaccurate documentation/writeups.)
> 
> 
> 
>      What I also found is that the error numbers do not appear to be
> 
> the same as those that I see for the same error in SSMS or any
> 
> reasonable transformation.  For example, a failed data conversion
> 
> (string to date) is 0x80040E14 with ODBC and 343 (0x157) with SSMS.  I
> 
> have been unable to find anything relating the two.  If you know,
> 
> please give me the URL.
> 

The former is an HRESULT. You have to mask off all but the least significant sixteen bits (0x0E14 or 3604 in this case).

http://en.wikipedia.org/wiki/HRESULT

Google returned the phone book for that ODBC error code, but this article indicates it means a duplicate key was ignored.

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_21026706.html

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Handling ODBC Connection Errors Gene Wirchenko <genew@ocis.net> - 2012-09-12 14:03 -0700
  Re: Handling ODBC Connection Errors Gene Wirchenko <genew@ocis.net> - 2012-09-12 19:33 -0700
    Re: Handling ODBC Connection Errors David Mark <dmark.cinsoft@gmail.com> - 2012-09-18 23:19 -0700
      Re: Handling ODBC Connection Errors David Mark <dmark.cinsoft@gmail.com> - 2012-09-18 23:26 -0700
  Re: Handling ODBC Connection Errors "J.R." <groups_jr-1@yahoo.com.br> - 2012-09-27 22:51 -0300
    Re: Handling ODBC Connection Errors Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-28 10:41 +0200
      Re: Handling ODBC Connection Errors "J.R." <groups_jr-1@yahoo.com.br> - 2012-09-28 15:29 -0700

csiph-web