Solved

Hard Code Native Error number in VB 6 program?

Posted on 2006-06-29
1
339 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Runtime 3044 error 14 50
Documenting Data flow 4 48
Question about Relationship and Userform in Access Database 17 62
SQL Query assistance 16 36
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Read about achieving the basic levels of HRIS security in the workplace.
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…

856 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