Topic: avoid a particular a record from deleting it from a tablegrid

Can I avoid a particular a record  from deleting it from a tablegrid ?

Re: avoid a particular a record from deleting it from a tablegrid

Hello,


I use a trick for records or data I don't want the user to delete : I had a boolean field called "can_delete" to a table, with default value set to 1 (true) and I set this value to 0 for the field marked as "undeletable".


Then it's just a matter of adding "AND can_delete=0" to your delete queries.


Hope it helps


Cheers



Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

3 (edited by v_pozidis 2015-12-09 09:16:04)

Re: avoid a particular a record from deleting it from a tablegrid

can you send me an example ? I am not a good programer.

Re: avoid a particular a record from deleting it from a tablegrid

Hello mathmatou

Ahh !! It's an old trick programmer and it is still effective !!

JB

Re: avoid a particular a record from deleting it from a tablegrid

ok but , can anyone send me an exaple to understand how to do that ?

Re: avoid a particular a record from deleting it from a tablegrid

v_pozidis wrote:

ok but , can anyone send me an exaple to understand how to do that ?

Example for you:

Post's attachments

Attachment icon Delete record prevent.zip 24.37 kb, 466 downloads since 2015-12-09 

Dmitry.

Re: avoid a particular a record from deleting it from a tablegrid

Dimitry,
Thanks for your quick response
this is the one what I was asking for.

Is there any manual for the syntax of the SQLExecute and where should I use the dots
( symbol  ' )

Re: avoid a particular a record from deleting it from a tablegrid

Hello v_posidis,


Forget about the SQLExecute, this is "just" the command that launches SQL Queries.


What you should focus on in the SQL syntax itself. You can find references all avor the internet, but here is a good (not the only one) source with examples :

http://www.w3schools.com/sql/sql_syntax.asp


In MVD, queries are triggered by the SQLExecute command, followed by the query itself like this :

SQLExecute('SOME SQL QUERY');

The "tricky" part is that, sometimes, you want to add variables to your queries, beeing text variables are integer variables.


Most of the time, you'll have to momentarely close theSQL syntx to add you variables and then reopen the query. something like this :


SQLExecute('SELECT name FROM customers WHERE name="'+mathias+'" AND id=5');

the " is to tell SQL you are looking for TEXT
the ' is to "close" the QUERY and begin the variable declaration
the + sign is the concatenate sign telling the query it is not finished and you are adding the variable there


then, after variable declaration, you have to do the same sequence but in reverse + and ' and finally "


Don't forget the LAST ' before the ) and ;


I hope I did not make any mistakes inmy example, those signs are confusing and a very small on my laptop screen for my "old eyes" smile


Tell me : are you by any chance trying to protect some records because, when th eproject is first launched, you have errors if you tables are empty ? Are is it something different ?


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: avoid a particular a record from deleting it from a tablegrid

Thanks for the help
* it works fine with the protected records. The idea was to have 3 records standard that no one could delete them. So I have those 3 records from the beginning in the tablegrid and the combobox.

Thanks again.