| View previous topic :: View next topic |
| Author |
Message |
C-Dizzle Grandmaster Cheater
Reputation: 89
Joined: 16 Mar 2008 Posts: 623
|
Posted: Sat Feb 25, 2012 11:38 am Post subject: Need VB & SQL help. |
|
|
My project works fine in college and used to work fine at home but I keep getting the error 'Invalid use of Null'. This is for a log on page using SQL and VB.
Here is the code. I know it's probably pretty shit but it's what the teacher taught us.
| Code: | Option Explicit
Private Sub cmdLogon_Click()
On Error GoTo ErrorTrap
'Connect to database
DBConnection
strSQL = "SELECT * FROM tblUsers "
strSQL = strSQL & "WHERE UserName = '" & txtUserName.Text & "' "
strSQL = strSQL & "AND UserPass = '" & txtUserPass.Text & "'"
objADOCon.Execute strSQL
'call the public sub in modDatabase (open a recordset)
OpenRecordset
'Populates variables with returned records
With objADORs
'keep going until you reach .EOF (end of file)
If Not .EOF Then
strUser = !UserName
strPass = !UserPass
intUserLevel = !UserPermission
End If
End With
'check if both username and password do not match
If Not txtUserName.Text = strUser And Not txtUserPass.Text = strPass Then
'username/password not found
'show a messagebox
If MsgBox("Access Denied. Login Credentials Mismatch.", vbCritical, "Mismatch") = vbOK Then
ResetScreen Me
'go no further
Exit Sub
End If
ElseIf txtUserName.Text = vbNullString And Not txtUserPass.Text = vbNullString Then
'username not provided
If MsgBox("Access Denied. You must supply a username.", vbCritical, "Username Input Required") = vbOK Then
txtUserName.SetFocus
End If
Exit Sub
ElseIf txtUserPass.Text = vbNullString And Not txtUserName.Text = vbNullString Then
'password not provided
If MsgBox("Access Denied. You must supply a password.", vbCritical, "Password Input Required") = vbOK Then
txtUserPass.SetFocus
End If
Exit Sub
ElseIf txtUserPass.Text = vbNullString And txtUserName.Text = vbNullString Then
'username and password not provided
If MsgBox("Access Denied. You must supply a username and password.", vbCritical, "No Login Provided") = vbOK Then
txtUserName.SetFocus
End If
Else 'got a match
'Stores UserID
intUserID = objADORs!UserID
'Stores UserName
strCurrentUser = objADORs!FirstName
'Stores Users points
intUserPoints = objADORs!UserPoints
'Display a mesage box to show that access is ok
MsgBox "You have successfully logged on. Your user level is: " & intUserLevel
End If
'Hides this form
Me.Hide
'Shows the main splash
frmMainSplash.Show
Exit Sub
ErrorTrap:
MsgBox "There has been an error. The error number is: " & Err.Number _
& " and the error description is: " & Err.Description
End Sub
|
|
|
| Back to top |
|
 |
Cryoma Member of the Year
Reputation: 198
Joined: 14 Jan 2009 Posts: 1819
|
Posted: Sat Feb 25, 2012 1:29 pm Post subject: |
|
|
| That's supposed to be php?
|
|
| Back to top |
|
 |
C-Dizzle Grandmaster Cheater
Reputation: 89
Joined: 16 Mar 2008 Posts: 623
|
Posted: Sat Feb 25, 2012 2:06 pm Post subject: |
|
|
| Cryoma wrote: | | That's supposed to be php? |
No. For my college computing class we need to make a program for a school points scenario. It's Visual basic and SQL <So I can use a database for accounts and what not>
|
|
| Back to top |
|
 |
Channel GannoK pffrt
Reputation: 130
Joined: 12 Apr 2008 Posts: 608
|
Posted: Sat Feb 25, 2012 2:12 pm Post subject: |
|
|
what IDE are you using. Express or pro?
_________________
|
|
| Back to top |
|
 |
C-Dizzle Grandmaster Cheater
Reputation: 89
Joined: 16 Mar 2008 Posts: 623
|
Posted: Sat Feb 25, 2012 2:20 pm Post subject: |
|
|
| GannoK wrote: | | what IDE are you using. Express or pro? |
Microsoft Visual Basic 6.0.
|
|
| Back to top |
|
 |
Cryoma Member of the Year
Reputation: 198
Joined: 14 Jan 2009 Posts: 1819
|
Posted: Sat Feb 25, 2012 2:23 pm Post subject: |
|
|
| Oh I thought you meant vbulletin, good luck with that.
|
|
| Back to top |
|
 |
TheIndianGuy Advanced Cheater
Reputation: 102
Joined: 14 Jan 2007 Posts: 85
|
Posted: Sat Feb 25, 2012 2:30 pm Post subject: |
|
|
| Arktri wrote: | | GannoK wrote: | | what IDE are you using. Express or pro? |
Microsoft Visual Basic 6.0. |
oh man what
|
|
| Back to top |
|
 |
C-Dizzle Grandmaster Cheater
Reputation: 89
Joined: 16 Mar 2008 Posts: 623
|
Posted: Sat Feb 25, 2012 2:31 pm Post subject: |
|
|
| TheIndianGuy wrote: | | Arktri wrote: | | GannoK wrote: | | what IDE are you using. Express or pro? |
Microsoft Visual Basic 6.0. |
oh man what |
Google failed me. I don't know what IDE is is.
|
|
| Back to top |
|
 |
Cryoma Member of the Year
Reputation: 198
Joined: 14 Jan 2009 Posts: 1819
|
Posted: Sat Feb 25, 2012 2:53 pm Post subject: |
|
|
| Arktri wrote: | | TheIndianGuy wrote: | | Arktri wrote: | | GannoK wrote: | | what IDE are you using. Express or pro? |
Microsoft Visual Basic 6.0. |
oh man what |
Google failed me. I don't know what IDE is is. |
If you're using VB6 then it's self explanatory so don't sweat it.
|
|
| Back to top |
|
 |
|