Results 1 to 8 of 8

Thread: [RESOLVED] Runtime Error 424

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Posts
    18

    Resolved [RESOLVED] Runtime Error 424

    I'm making a login program to get the usernames and passwords from a mysql database but i get Runtime Error 424.

    Code:
          Private Sub cmdLogin_Click()
    
          Dim SQL As String
       
          Dim conn As ADODB.Connection
    
          Set conn = New ADODB.Connection
       
          Dim rs As ADODB.Recordset
       
          Set rs = New ADODB.Recordset
       
          conn.CursorLocation = adUseClient
    
    conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & "SERVER=ip;" & "DATABASE=dbname;" & "UID=username;" & "PWD=password;" & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
          conn.Open conn.ConnectionString
      
          SQL = "SELECT * FROM authorized  WHERE username = '" & txtUsername.Text & "' AND password = '" & txtPassword.Text & "'"
        
          rs.Open SQL, conn, adOpenStatic, adLockReadOnly
    The yellow line is what Visual Basic said is causing the problem.
    Last edited by tipsyhitman; Aug 25th, 2007 at 05:06 PM. Reason: Clean code up

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Runtime Error 424

    Welcome to the Forums

    Is txtUsername.Text and txtPassword.Text exist on your form and spelled correctly?

    Ps, that yellow is soo hard to read
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Posts
    18

    Re: Runtime Error 424

    Code:
          Private Sub cmdLogin_Click()
    
          Dim SQL As String
       
          Dim conn As ADODB.Connection
    
          Set conn = New ADODB.Connection
                 
          Dim rs As ADODB.Recordset
       
          Set rs = New ADODB.Recordset
       
          conn.CursorLocation = adUseClient
      
    conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & "SERVER=ip;" & "DATABASE=dbname;" & "UID=username;" & "PWD=password;" & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
             
          conn.Open conn.ConnectionString
      
          SQL = "SELECT * FROM authorized  WHERE username = '" & txtUsername.Text & "' AND password = '" & txtPassword.Text & "'"
    
          rs.Open SQL, conn, adOpenStatic, adLockReadOnly
    
          If rs.EOF Then
      
            MsgBox "Invalid Login"
      
          Else
      
            MsgBox "Logged in as " & rs!UserName
      
          End If
      
          rs.Close
      
          Set rs = Nothing
      
          conn.Close
      
          Set conn = Nothing
      
          End Sub
    Ok thats the code that im having problems with.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Runtime Error 424

    Quote Originally Posted by RobDog888
    Is txtUsername.Text and txtPassword.Text exist on your form and spelled correctly?
    How about this part of my post?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Posts
    18

    Re: Runtime Error 424

    No, I don't think so.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Runtime Error 424

    Well that is where the problem is as it cant resolve the "objects" to anything on your form.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Posts
    18

    Re: Runtime Error 424

    Thanks i fixed it, i had txt.User instead of txt.username.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Runtime Error 424

    Cool, glad its working now.

    Ps, as a newer member I will tell you that its easier for members to know your thread has been solved by you going to the Thread Tools menu and selecting "Mark Thread as Resolved".
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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