Hello!

I am very pleased to join Daniweb. I found it very interesting and helpful and immediately joined the community in the hope of getting some help regarding my final year project.


Well coming to the point, m designing an Attendance Management System(AMS) for my college.
I have created accounts for Admin, Teacher and Principal. I want to know how to retrieve the username and password from the database and use it to verify with the username and password which users will provide in my AMS's login page.

Also, how to retrieve only a particular students information.ie i provide the student id and want to get only that particular students information. Need some help with the queries.

Thanks!

What have you done so far, can you show us some codes?

So far i've done only the adding part using the dataenvironment and datagrid control. Would like to know what control to use to retrieve data using sql queries. I would definitely show you the codes once i start working on retrieving data.
what is the difference in using the data grid, hierarchical flexgrid and adoc controls?

K here's the code.
I want to retrieve the password from database table and then compare it and verify instead of doing it this way. How do i do it?

Private Sub cmdEnter_Click()
If (Trim(txtPassword.Text) = "computer") Then
txtPassword.Text = ""
Main.Hide
TeachersZone.Show
ElseIf (txtPassword.Text = "") Then
MsgBox ("Please enter the Password!")
txtPassword.SetFocus
Else
MsgBox ("Incorrect Password!")
txtPassword.Text = ""
txtPassword.SetFocus

End If
End Sub

Try:

Put this on your General Declarations:

Option Explicit

'this part detects if the user press Enter Key 

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const KEY_TOGGLED As Integer = &H1
Private Const KEY_PRESSED As Integer = &H1000

Dim db As ADODB.Connection
Dim rs As ADODB.Recordset

Then on your Login Command button

Dim User As String
Dim CurrentPosition As String

'Sets the database connection

Set db = New ADODB.Connection
        db.CursorLocation = adUseClient
        db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\Database.mdb"
    
'Change the path to you database drive path or folder location
'Change Database.mdb with your database name w/o removing the ".mdb" extension

'Set the recordset connection on a Table

Set rs = New ADODB.Recordset
        rs.Open "select * from TableName where Fieldname = '" & txtPassword & "'", db, adOpenStatic, adLockOptimistic

'Change Tablename to your database table name
'Change Fieldname to your database table field name

'Detects whether the textbox is empty

If LenB(txtPass.Text) = 0 Then
        
    MsgBox "Empty entry. Please provide a valid password.", vbExclamation, "Error"
    Exit Sub
    
End If

If txtPass.Text = rs.Fields("Fieldname").Value Then
'check if the values entered are present on the Password field of the Database table

        User = txtPass.Text
        CurrentPosition = rs.Fields("Fieldname")  'Change Fieldname
                   
        MsgBox "Acces granted.", vbInformation, "Prompt"
        
        rs.Close
        db.Close
        
        Unload Me
        TeachersZone.Show
        
    Else
            
        MsgBox "Invalid Password.", vbCritical, "Error"
        txtPassword.Text = vbNullString
        txtPassword.SetFocus
        
       
    End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.