Error works like Message

hi All,

I wrote a piece of code in Codeunit 1 like this

on loginstart()

IF (UPPERCASE(USERID) <>‘SA’) THEN
ERROR('DATABASE IS BLOCKED FOR YOU);

but when the user sa login he gets the error ‘DATABASE IS BLOCKED FOR YOU’, but when click on that error he still accessing the database

i want to allow only 1 user to the database

Then simply remove the users from Windows Authentication or Database Authentication…

Hi Mohana

It is just for 1 day & i have around 40 users

i want to allow only 1 user for that day

You cant stop logging in by writing Error in CU1…

If its Database logins you can set expiration dates in user table for all other users, whom you dont wanna allow login.

How i can i achieve this by allowing one user and blocking all users at that time

I Have windows users.

Altering Databases - Options Tab

On the Options tab of the Alter Database window, you can change any of the database options that you set when you created the database. For example, you must select the Single User option before carrying out any database tests. You must cancel the selection of this option when the tests are completed.

Single user: If you select this option, only one user can access the database at a time. This setting can be used when you are carrying out administrative functions such as testing or restoring the database. By limiting access to the database to one user, in this case yourself, you ensure that the database is not altered while you are testing it. Remember to clear this check box when you are finished.

i want to allow database for the specific user, i think if we select single user the first one will have access and the next user will not.

Eg: i want to allow for the user ‘sa’

keep logged in ‘sa’ always [:)]

More clear not single user , specific users(3 or 4) to allow and for remainig users restrict the database

If you wanna do temporariely you can also remove their access from SQL to the particular database

there is also one more option in Alter Database Options tab

Members of db_owner, dbcreator or sysadmin: If you select this option, only members of the db_owner fixed database role, the dbcreator fixed server role or the sysadmin fixed server role have access to the database.