first row login problem and also add a no multiple login

farukh

New member
Joined
Nov 13, 2014
Messages
2
Programming Experience
Beginner
Hello,
I am new at vb.net coding. I am having a problem with my login form which is connected to a mysql database. Please help me out for solving the problem.

My Database Connection Code:


Code:
Public dblink As String = "server="Host"; port=3306; uid="username"; password="password"; database="dbname";"
Public conn As New MySqlConnection(dblink)


My Login Sub:

Code:
login.Cursor = Cursors.AppStarting
If Not conn.State = ConnectionState.Broken Then
Try
ds = New DataSet
da = New MySqlDataAdapter("SELECT * FROM members WHERE status=0", conn)
da.Fill(ds, "members")

If ds.Tables("members").Rows.Count > 0 Then
'For i As Integer = 0 To ds.Tables("members").Rows.Count - 1
If Not ds.Tables("members").Rows(0).Item(2).ToString = login.tbx_username.Text Then
login.Cursor = Cursors.Default
MsgBox("Login Failed. Account doesn't exist." & vbCrLf & "Please sign up first to gain access!!!", MsgBoxStyle.Critical, "ERROR")
login.tbx_username.Focus()
Else
If ds.Tables("members").Rows(0).Item(3).ToString = login.tbx_password.Text Then
login.prgbar_login.Visible = True
login.prgbar_login.IsRunning = True
Try
ds = New DataSet
da = New MySqlDataAdapter("UPDATE members SET status=1 WHERE username='" & login.tbx_username.Text & "'", conn)
da.Fill(ds, "members")
Catch ex As Exception
login.Cursor = Cursors.Default
MsgBox("ERROR #108: Error in login database query. Please report the error number to the developer.", MsgBoxStyle.Critical, "ERROR")
End Try
login.tmr_login.Start()
Else
login.Cursor = Cursors.Default
MsgBox("Login Failed. Incorrect Credentials. Please try again with correct credentials.", MsgBoxStyle.Critical, "ERROR")
login.tbx_password.Focus()
End If
End If
'Next
Else
login.Cursor = Cursors.Default
MsgBox("Login Failed. Incorrect Credentials. Please try again with correct credentials.", MsgBoxStyle.Critical, "ERROR")
login.tbx_username.Focus()
End If
Catch ex As Exception
login.Cursor = Cursors.Default
MsgBox("ERROR #109: No multiple logins allowed.", MsgBoxStyle.Critical, "ERROR")
login.Close()
End Try
Else
login.Cursor = Cursors.Default
MsgBox("Server connection timeout. Check your connection & try again !!!", MsgBoxStyle.Critical, "Server Connection Timeout")
login.Close()
End If


This sub has been called on login form load event using:
Code:
Call userLogin()

Database Snapshot:
attachment.php


Database Member table Snapshot:
attachment.php


Database Members Table Structure:
attachment.php



Now please tell me how I can correct the only first row login problem and also add a no multiple login system to my login system.
 
first row login pproblem?,, for no multiple login, add a userlog which time logged in ,logout etc.. then in your system check if the user trying to log is still logged in or not..
 
Back
Top