Well, whatever solution you end up using, be sure to use some sort of obfuscator to make it more difficult for the user to reverse engineer.
OK, storing user names in the database probably isn't good enough. You can limit concurrent users this way perhaps, but whoever owns the database has the power to edit this table, which would mean they can swap users in & out at their convenience.
How about this - maintain an encrypted file which lists all registered users. Users can register only using your program, which will limit the number of registered users allowed. Since it's encrypted, the users should have a hard time editing this file. They could swap it for an old copy perhaps, which may be useful in some cases. (Esp if you allow users to unregister, which might undermine this whole system.) You can make this more difficult by also storing the time of last access in this file, as well as other places on the system (like in the DB). If your program finds evidence of other accesses more recent than what the file indicates, it can disable itself somehow. (Of course, you'll want to
test this very carefully before releasing it to the coderanch.)

Hmmm... if you allow unregistration or license transfer, what would prevent users from swapping the license regularly - so that again, you're only limiting concurrent users, not total users? Offhand, the encrypted user file could also include records of former users. You could put in limits then - e.g. "once a given user is unregistered, they can never reregister" or "no more than one reregistration per user". Or the overall license could be for X total users, with Y allowable unregistrations (so the total number of users in the product lifetime would be X + Y, since each unregistration allows one more registration of a different user. You can even make it so that exceeding limit Y simply forces the users to contact your company to get a new license file. This allows you to review their situation and see if there's a justification for all the reassignments. Did they go through a reorganization of some sort, with lots of new hires? Or are they just swapping licenses between the same users?