It'll take a little time to put a mockup together, but a few things I can say right now are that you really shouldn't be doing this in a widget, those queries look VERY injectable, and also that you're running queries you don't really need to run. How are you establishing initial communication with the server?
Looks like you're using the MSSQL integration from the marketplace, which does not mention prepared statements anywhere in its store page or documentation. I don't own it, so I can't speak to how anything actually gets done behind the scenes, but I'd be concerned about that. I do own NetDB, which works with a PostgreSQL database, and does support prepared statements. Might want to look into that before you get too far in the process. It shouldn't be too painful to migrate, as they're generally very similar.
Your widget will not exist on the server. I'd recommend handling database operations via the controller and (server) game instance, and storing anything you need to keep on-hand in the (client) game instance. This will allow you to respect authority.
Also consider changing your query to something like `SELECT AccountPassword FROM Accounts WHERE AccountName = accountName;` as this will only return one row if you're enforcing account name uniqueness correctly. This will be gentler on your database, and you won't have to do so much looping to handle the response.