Solved

Hard Code Native Error number in VB 6 program?

Posted on 2006-06-29
1
332 Views
Last Modified: 2010-08-05
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,

Laurencel



 
0
Comment
Question by:misdevelopers
1 Comment
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 125 total points
ID: 17015064
Since these are SQL Server errors and not ADO error numbers, they will remain the same for backward compatibility, at least in 2000 and 2005 :)

This is the current description in SQL Server 2000:
4060: Cannot open database requested in login '%.*ls'. Login fails.
18456: Login failed for user '%ls'.

And this in SQL Server 2005
4060:  Cannot open database "%.*ls" requested by the login. The login failed.
18456:  Login failed for user '%.*ls'.%.*ls

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: I have seen many questions on EE and elsewhere, asking about how to find either gaps in lists of numbers (id field, usually) ranges of values or dates overlapping date ranges combined date ranges I thought it would be a good …
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now