|
-
Aug 25th, 2007, 05:04 PM
#1
Thread Starter
Junior Member
[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
-
Aug 25th, 2007, 05:07 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 25th, 2007, 05:11 PM
#3
Thread Starter
Junior Member
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.
-
Aug 25th, 2007, 05:17 PM
#4
Re: Runtime Error 424
 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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 25th, 2007, 05:19 PM
#5
Thread Starter
Junior Member
-
Aug 25th, 2007, 05:20 PM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 25th, 2007, 05:20 PM
#7
Thread Starter
Junior Member
Re: Runtime Error 424
Thanks i fixed it, i had txt.User instead of txt.username.
-
Aug 25th, 2007, 05:27 PM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|