Results 1 to 4 of 4

Thread: SQL User info validated in VB

  1. #1

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Exclamation

    I am trying to create an application that uses the SQL users and password logins and validate them in VB so that I can enable and disable various commands/buttons and also give out a message box if the username or password entered by the user is invalid. Is there a way I can authenticate the username and password in the application without using a stored procedure. I hope this request is not confusing.
    This is what I have so far:

    cn.Open "PROVIDER=MSDASQL;dsn=QCManager;uid=" & txtuName.Text & ";pwd=" & txtPword.Text & ";database=QCManager;"

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    If you want to get user names from the database, first you have to have appropriate rights to do that.

    The easiest way to do it is to open a connection based on the login that the user specifies. Also, add On Error GoTo or On Error Resume Next statement to check if the connection was successful. If YES then user has valid login and password - otherwise NO.

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    At what point

    If I understand correctly...

    You want to do that at LOGIN time
    Let the system help you

    a. Use this function

    'Example of the call to the function
    'Get a connection and if not succesful bye...
    If GetNewConnection(m_objConn) <> adStateOpen Then
    Unload Me
    Exit Sub
    End If

    'This function will pop up the Microsoft prompt
    'and checks will be made for you as to user is
    'valid or not...

    Public Function GetNewConnection(ByRef ArgConnObj As ADODB.Connection) As Integer

    On Error GoTo GetNewConnection_Error

    Set ArgConnObj = New ADODB.Connection

    With ArgConnObj
    .Provider = "sqloledb"
    .Properties("prompt") = adPromptComplete
    .Open

    GetNewConnection = .State

    End With

    Exit Function

    Let me know....

  4. #4

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Talking Thank you, but need more help!

    Thank you for your previous assistance, but I need more help. I used the on error goto line and it did work but now I need to find a way for VB to check the rights of the logged in user so that I can enable some commands. for example, if the user has admin rights, I would like to enable all buttons/commands. Any suggestions?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width