Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 22nd, 2007, 01:26 PM
Authorized User
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default How to determine login success or failure?

My application is a Windows application, using SQL 2K5 as the back end database.
I have a login screen designed and working with faked data. (Thanks, Woody Z and Doug, for all your help.)

What I haven't figured out yet is how to determine whether the login succeeded or failed. Almost every example I see shows integrated security, which the users will be using when we reach production, but during the testing, I want to be able to test SQL Server authentication.
I know how to create the connection string, but I haven't seen an example of how to just check connection rights to the server and database and pull back the users' granted permissions without executing a SQL command. Or am I thinking about this incorrectly?

Old January 22nd, 2007, 02:31 PM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

hmmmm. In so far as SQL 2K5 I am not entirely sure. If i wanted to check whether or not a user existed in SQL server on a SQL 2K box I could compare the data provided to the data that is in the sysusers tables. Granted, this would only tell me if the user existed inside of SQL, to actually check the password I am not sure. You could build the connection string with the credientials provided and execute a rudimentary SQL query and then handle the SQL Exception that is generated when the SQL Logon fails.

Unfortunately, there isn't a certain SQL Execption that you can check for, it will just be of type SqlException, however, to verifiy that it is infact a login failure, you can check the exception message for the existance of the string: "Logon failed for user:" and if the position of that string is not -1 then you know the user has provided invalid credentials else it is a SQL exception that you need to handle.


================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========

Similar Threads
Thread Thread Starter Forum Replies Last Post
Photo login failure pchee373 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 June 29th, 2007 02:25 PM
login failure yasminnnnn BOOK: ASP.NET Website Programming Problem-Design-Solution 2 February 27th, 2007 04:16 AM
Login Failure Basia BOOK: ASP.NET Website Programming Problem-Design-Solution 6 November 1st, 2005 08:33 PM
Another Login failure Bo.B.B BOOK: Beginning VB.NET Databases 6 July 10th, 2005 04:02 AM
login as 'sa' failure - need to restore BAK bful SQL Server 2000 2 November 16th, 2003 03:33 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.