CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> ASP

 Omit if Empty

Print topic Send  topic

Author Message

Posts: 3
Posted: 07/16/2010, 5:42 AM

I usually use CCS for PHP programming, but today I need to modify ASP app written with CCS.

How can I use omit if empty feature in ASP?

I have a record form with some fields on it which are specified in custom update method.
In particular situation I would like to exclude some of these fields from update operation, how can I achieve that?

I thought I could set the particular field to NULL (Empty in ASP I guess) in BEFORE UPDATE event, but it doesn't seem to work.

I dug into the source code generated by css:

Dim IsDef_Invest_Year : IsDef_Invest_Year = CCIsDefined("Invest_Year" , "Control")  
Dim IsDef_Invest_Month : IsDef_Invest_Month = CCIsDefined("Invest_Month" , "Control")  

If Not UpdateOmitIfEmpty("SiteID") Or IsDef_SiteID Then Cmd.AddSQLStrings "[SiteID]=" & Connection.ToSQL(Cmd.Parameters.getParamByID(1), Cmd.Parameters.getParamByID(1).DataType), Empty  
If Not UpdateOmitIfEmpty("Invest_Year") Or IsDef_Invest_Year Then Cmd.AddSQLStrings "[Invest_Year]=" & Connection.ToSQL(Cmd.Parameters.getParamByID(2), Cmd.Parameters.getParamByID(2).DataType), Empty  


'CCIsDefined @0-519FFE4F  
  Function CCIsDefined(ParameterName, Scope)  
   Select Case Scope  
     Case "URL"   
        CCIsDefined = Not IsEmpty(Request.QueryString(ParameterName))  
     Case "Form","Control"  
        If IsMutipartEncoding Then  
    	  CCIsDefined = Not IsEmpty(objUpload.Form(ParameterName))  
    	  CCIsDefined = Not IsEmpty(Request.Form(ParameterName))  
    	End If  

... and it seems to me that if I have some data submitted by the form (in POST) then I cannot omit that data in the query ... but since I use ASP very rarely I might be wrong and I hope I am wrong.
Could you advice how to proceed? Maybe there is different approach?

View profile  Send private message

Posts: 53
Posted: 07/16/2010, 10:31 AM

What does UpdateOmitIfEmpty() do? I couldn't find it in any of the common files.
View profile  Send private message

Posts: 3
Posted: 07/16/2010, 12:24 PM

UpdateOmitIfEmpty() is a function that returns boolean TRUE if particular field has (in custom update) defined if parameter is empty do not update the Field.
This setting depends (as far as I remember) on the general project setting Exclude missing fields/parameters from data updates.

In PHP in CCS I can do the following.
I have a record form and 5 fields that are used in UPDATE.
If based on some condition I want to exclude a field from update it is enough to set its value to NULL or to remove the array field responsible for that field, e.g.
$Component->UpdateFields["SiteID"]["Value"] = NULL;  

I couldn't find the counterpart in ASP.

For the time being I created the second form with only a few fields that are being updated and I show one of the forms depends of what I want to update. But I don't like that "solution".


View profile  Send private message

Posts: 53
Posted: 07/16/2010, 12:35 PM

I did a quick test of IsEmpty with a querystring. I made a page that contains the following code.

<% = isempty( request.querystring("hello") ) %>  

If you visit the page with an empty querystring you'll see that isempty is true. However, if you include ?hello= as the querystring isEmpty returns false. It seems if the querystring or form item exists in the get/post request it is considered blank "" and not empty.

With this insight in mind the following code should get your function to return the desired result.

function UpdateOmitIfEmpty(param_name)  
    if request.form(param_name)&"" = "" then   
        ' it's blank/no value  
        UpdateOmitIfEmpty = true  
        ' it has  a value assigned  
        UpdateOmitIfEmpty = false  
    end if  
end function  
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

Web Database

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

Home   |    Search   |    Members   |    Register   |    Login

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