Do you have any more done than that? I ask because the answer is different depending on how things are set up.
If I assume that the AgentID column is a column in the same table that has username and password (which would make sense, as it could easily be either a primary key, or something else), then I would be writing the code something like this (assuming a SQL Server DB):
Code:
Using cn As New SQLClient.SQLConnection(some connection string)
Using cmd As SQLClient.SQLCommand = cn.CreateCommand
Try
cn.Open
cmd.CommandText = "SELECT AgentID FROM Users WHERE Username = @p1 AND Password = @p2"
cmd.Parameters.AddWithValue("@p1",some user name)
cmd.Parameters.AddWithValue("@p2",some password)
Dim obj As Object = cmd.ExectueScalar
If Obj Is Not Nothing Then
AgentIDNumber = CInt(obj)
Else
'You got nothing, what do you want to do?
End If
Catch ex As Exception
'Do something here, even if just show a message.
End Try
End Using
End Using