Solved

Hard Code Native Error number in VB 6 program?

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Client backup and data retention? 3 54
How can I find a table in SQL server 2016 4 51
SQL Server Determine if date is recurrance date 3 46
report returning null 21 79
APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
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…

947 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

20 Experts available now in Live!

Get 1:1 Help Now