sjgrodriguez
Posts: 26
|
Posted: 09/18/2011, 2:37 AM |
|
Hi there. I have a problem using custom insert and update with editable grid.
I want to insert new rows in the "analysis" table , based on the rows from the editable grid. However, i want to be inserted only those rows checked true with a checkbox field added to the editable grid, called "Enviar".
The INSERT INTO sentence used in the CUSTOM INSERT and CUSTOM UPDATE SQL is:
INSERT INTO ENSAYOS_RECEPCION(Ensayo, cod_muestra, Enviar) VALUES('{Ensayo}', {cod_muestra}, {Enviar}) WHERE ({Enviar}=True)
This code gives me an error, probably because the WHERE Clause cannot be used together with VALUES clause.
Does anyone know how to solve this problem? I mean, to insert only those rows checked true.
Thanks in advance,
Sergio Gómez
|
|
|
Livinus
Posts: 48
|
Posted: 09/18/2011, 5:07 PM |
|
I think you need to use the INSERT INTO ... SELLECT construct to achieve that.
|
|
|
mljonzs
Posts: 124
|
Posted: 09/19/2011, 7:07 AM |
|
There is an attribute on the Data Source called CmdExecution that is used in editable grids to determine whether each line on the grid should be affected by Insert/Update/Delete. Code or action on the record can cause this attribute to be set to True so that it goes to the database. In your case, if you add code to the BeforeExecuteInsert event that checks to see if your Enviar is set to False so you can prevent the insert statement from running on records not flagged.
For example in the BeforeExecuteInsert, add something like :
If <yourGrid>.Enviar.value = FALSE Then <yourGrid>.DataSource.CmdExecution = False End If
Then, take the WHERE clause off of your insert and it should work for you.
Hope this helps you....
mljonzs
_________________
What does not begin WITH God, will end in failure!
|
|
|
sjgrodriguez
Posts: 26
|
Posted: 09/19/2011, 7:25 AM |
|
Hey mljonzs, This is simply great. It works perfectly as i wanted.
Thanks !
Sergio Gomez
|
|
|
|