Wednesday, March 7, 2012

Hard Code Native Error code in program?

Using VB 6, sp6,
On sql server 2000 (sp4)
When I try to establish a connection to the database
from a VB 6 program using ADO, I get a similar message
if the UserID does not exist or if the UserID does exist
but does not have the permission to the database.
The NativeError number is different,
NativeError - 18456 The UserID does not exist
NativeError - 4060 The UserID exists, but does not have permission
to the database.
Can I hard code the NativeError number in my VB 6
program to determine exactly what happened,
(the UserID did not exist or the UserID does exist but
does not have the proper permission.)
I worry that the code number might change in a future
version of sql server.
I hate to do this but there is no other way to determine
exactly what happened.
Thanks in Advance,
Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing EducationIt's unlikely that the error codes would change. Could happen, but more
probable that additional codes would be added for other (and new)
situations.
If you are concerned, you could use a config file, and put the codes in the
config file. Have the app read the config file at start up and hold the
error codes in global variables. (An xml file works good for that.)
Otherwise, set them up as constants.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"Larry" <bliff@.Blifff.com> wrote in message
news:OlggCs6mGHA.2360@.TK2MSFTNGP04.phx.gbl...
> Using VB 6, sp6,
> On sql server 2000 (sp4)
> When I try to establish a connection to the database
> from a VB 6 program using ADO, I get a similar message
> if the UserID does not exist or if the UserID does exist
> but does not have the permission to the database.
> The NativeError number is different,
> NativeError - 18456 The UserID does not exist
> NativeError - 4060 The UserID exists, but does not have permission
> to the database.
> Can I hard code the NativeError number in my VB 6
> program to determine exactly what happened,
> (the UserID did not exist or the UserID does exist but
> does not have the proper permission.)
> I worry that the code number might change in a future
> version of sql server.
> I hate to do this but there is no other way to determine
> exactly what happened.
> Thanks in Advance,
> Laurence Nuttall
> Programmer Analyst III
> UCLA - Division of Continuing Education
>
>|||It's unlikely that the error codes would change. Could happen, but more
probable that additional codes would be added for other (and new)
situations.
If you are concerned, you could use a config file, and put the codes in the
config file. Have the app read the config file at start up and hold the
error codes in global variables. (An xml file works good for that.)
Otherwise, set them up as constants.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"Larry" <bliff@.Blifff.com> wrote in message
news:OlggCs6mGHA.2360@.TK2MSFTNGP04.phx.gbl...
> Using VB 6, sp6,
> On sql server 2000 (sp4)
> When I try to establish a connection to the database
> from a VB 6 program using ADO, I get a similar message
> if the UserID does not exist or if the UserID does exist
> but does not have the permission to the database.
> The NativeError number is different,
> NativeError - 18456 The UserID does not exist
> NativeError - 4060 The UserID exists, but does not have permission
> to the database.
> Can I hard code the NativeError number in my VB 6
> program to determine exactly what happened,
> (the UserID did not exist or the UserID does exist but
> does not have the proper permission.)
> I worry that the code number might change in a future
> version of sql server.
> I hate to do this but there is no other way to determine
> exactly what happened.
> Thanks in Advance,
> Laurence Nuttall
> Programmer Analyst III
> UCLA - Division of Continuing Education
>
>

No comments:

Post a Comment