Solved

Hard Code Native Error number in VB 6 program?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Latency in .net app using DB in .net 21 63
Server configuration for MS Access - SQL Server app 8 69
form builder not starting 3 34
Querying data from 3 SQL tables 2 31
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
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…

776 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