Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to lock database/table to a certain amount of users/rows??

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I wonder if it is possible to lock a database/table to a certain amount of users/rows.

What I want to do is:
I want to distribute my application in different versions. One has a limit of maybe 4 users, an other a limit of 40 users, the third has a limit of 400 users.

In the database, in one of the tables, different subscribers are entered (this is done through my software) and the point is that when and end-user (who bought the 4-user limit version of my software) has entered 4 subscribers with my program, then he shouldn't be able to enter any more subscribers. This is, the software I distribute is the same to all customers, but they get different versions of the database depending on what version they bought.

I am using SQL Server7 and am wondering if this is possible to do at database-level.

Thanks for any help!

regards Bob Nachbar
 
My first thought is to create an insert trigger on the table; this trigger checks the authorization level, then rolls back if the new record would exceed that count. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Thanks Robert Bradley. I am trying to make a trigger now, but I don't know exactly how the syntax should be as I've never created a trigger before. I have something like this now but it needs changes:

CREATE TRIGGER rowcheck
ON subscribers
FOR INSERT AS
IF
(SELECT DISTINCT COUNT([id]) FROM subscribers) >4
BEGIN
don't let the user add any more rows
END
ELSE
BEGIN
okay, let the user add the row
END

What syntax should I have to make this work?!

Thanks!

//Bob
 
I solved it by using just typing in:
rollback

It seems to work okay. But I suppose this method isn't very &quot;secure&quot;, I mean, it wouldn't really work to distribute these different kinds of databases as anyone would be able to change the value (the amount of subscribers of the version they bought) in the trigger...
 
You could encrypt the value in the table where you store the max number of subscribers, then put a constraint on it.

For example, say you have an integer column and store the maximum number of subscribers x 37 to that column. In your trigger, you'll always divide that max column by 37 to arrive at the max number of subscribers. Further, to prevent them from toying with that column, but a constraint on it so that MaxSubs % 37 = 0; that way, they'd be unlikely to stumble across just the right number to put in there. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top