CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 INSERT INTO WITH "WHERE" CLAUSE

Print topic Send  topic

Author Message
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



View profile  Send private message
Livinus

Posts: 48
Posted: 09/18/2011, 5:07 PM

I think you need to use the INSERT INTO ... SELLECT construct to achieve that.
View profile  Send private message
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!
View profile  Send private message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.