Results 1 to 7 of 7

Thread: Login and security error

  1. #1

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

    Lightbulb

    Hi Everybody!

    I hope you can help me. I have my application logging into my SQL server 7.0 for user security. I can log in to my login screen, but the application seems to not hold on to the username and password when I try to open other forms in the application. It gives me this error:

    Run-time error '-2147217843(80040e4d)':
    Login failed for user '(null)'

    Here is a sample of what I have on Form_load on the forms that give me the error:

    Code:
    Set cn = New Connection
        cn.Provider = "SQLOLEDB.1"
        cn.ConnectionString = "DATABASE=QCManager;SERVER=d248r00b;UID=" & A_Sign_On.txtuName.Text & ";PWD=" & A_Sign_On.txtPword.Text & ";"
        cn.Open
    A_Sign_On.txtuName.Text and A_Sign_On.txtPword.Text are the username and password respectively. A_Sign_On is the form where the user puts in the username and password.

    Any ideas on how to solve this problem?

    Thanks in advance.

    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

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

    ?!

    That could eb the wrong answer

    but have not tried it or anything

    and am not sure which version of VB u're using


    Try

    'A.signon!textname.text' etc..

  3. #3

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

    Unhappy Hmm...

    My version for VB is 6.0, Service Pack 4, and SQL 7.0 Service Pack 2. Still did not work with
    A_Sign_On!txtuName.Text

    Any assistance would be greatly appreciated.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

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

    ..

    Hi!
    Try this... (quickie also)

    Q. Is your form still loaded (i.e the form that contains the password...?

    Debug a bit with msgbox...
    (or I can send u a small function that I use)



    Dim cn As ADODB.Connection
    Dim strCnn As String
    dim myuserID, mypwd

    myuserID = A_Sign_On.txtuName.Text
    msgbox myuserID
    mypwd = A_Sign_On.txtPword.Text
    msgbox mypwd

    ' Open connection.
    strCnn = "Provider=sqloledb;" & _
    "Data Source=d248r00b;Initial Catalog=QCManager;User Id=" & myuserID & " ;Password= " & mypwd & "; "

    Set cn = New ADODB.Connection
    with cn
    .ConnectionTimeout = 30000 'a little bit more than 2hrs
    .CommandTimeout = 30000
    .open strCnn
    end with

  5. #5

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

    Unhappy Hi!

    Yes , my form where the user has put in the username and password is unloaded. Basically, I need for the username and password to follow the user all over the application until he/she logs out of the app.

    Any ideas?

    Thanks again in advance.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

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

    global var

    put it in a global variable

    under General ---> Declarations section
    in a module or your frm

    Public SaveUserID as string
    Public SavePwd as string


    then right where u have these pieces of info

    do

    SaveUserID = ...


    etc..

    then u should be able to reference these global vars
    from anywhere with your prog

  7. #7

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

    Talking Thanks!

    It is working!!!!!! Thanks for your help.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

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