I have returning datatable which has a cell value of Nothing that passed from function ex. row("incident_idcrimes") is a column in a datable
Controller.GetCrime(row("incident_idcrimes")) is function that returns either has a value or nothing.
If it catch a return value of nothing using try catch then it will
Return Nothing
how do i create a formula that catch from passing function?
IF ISNULL({STAT.IDCRIMES}) = TRUE THEN "NONE" ELSE {STAT.IDCRIMES}
this formula give me an error
ISNULL({STAT.IDCRIMES})
this itself returns boolean (either true or false), what is the purpose of comparing this value again?
you can change as
IF ISNULL({STAT.IDCRIMES})
THEN "NONE"
ELSE {STAT.IDCRIMES}
Edit*****************
IF {STAT.IDCRIMES}=cstr("")
THEN "NONE"
ELSE {STAT.IDCRIMES}
Related
Why when I pass false to Model::where() and then trying to get first() element it always returns me first element instead of null?
Example:
I have Referrer model with hash_id = 123aSd456fGh
and I try to get this like below:
$requestReferrer = false;
$referrer = Referrer::where('hash_id', $requestReferrer)->first();
dd($referrer); // returns first Referrer model with hash_id = 123aSd456fGh
FYI
when I pass null in exchange for false it returns null.
Reason:
SQL Server will automatically change the bit value to the varchar value of true or false.
The following works there:
$requestReferrer=false;
$referrer = Referrer::where('hash_id', "$requestReferrer")->first();
Or
$requestReferrer = 'false';
$referrer=Referrer::where('hash_id',$requestReferrer)->first();
I´m trying to save a value in spreadsheet's header for later use as a new column value.
This is the reduced version with value (XYZ) in header:
The value in header must be used for new column CODE:
This is my design:
tFilterRow_1 is used to reject rows without values in A, B, C columns.
There is a conditional in tJavaRow_1 to set a global variable:
if(String.valueOf(row1.col_a).equals("CODE:")){
globalMap.putIfAbsent("code", row1.col_b);
}
The Var expression in tMap_1 to get the global variable is:
(String)globalMap.get("code")
The Var "code" is mapped to column "code" but I'm getting this output:
a1|b1|c1|
a2|b2|c2|
a3|b3|c3|
What is missed or there is a better approach to accomplish this escenario ?
Thanks in advance.
Short answer:
I tJavaRow use the input_row or the actual rowN in this case row4.
Longer answer, how I'd do it.
I'd do is let the excel flow in AS-IS. By using some Java tricks we can simply skip the first few rows then let the rest of the flow go through.
So the filter + tjavarow combo can be replaced with a tJavaFlex.
tJavaFlex I'd do:
begin:
boolean contentFound = false;
main
if(input_row.col1 != null && input_row.col1.equalsIgnoreCase("Code:") ) {
globalMap.put("code",input_row.col2);
}
if(input_row.col1 != null && input_row.col1.equalsIgnoreCase("Column A:") ) {
contentFound = true;
} else {
if(false == contentFound) continue;
}
This way you'll simply skip the first few records (i.e header) and only care about the actual data.
How to add FirstOrDefault value into cshtml dropdownlist?
Controller: Gets First Customer that has CustomerActive == false
CUSTOMERLIST singleCustomer = db.CUSTOMERLIST.FirstOrDefault(s => s.CustomerActive == false);
ViewBag.SingleCustomer= singleCustomer;
CSHTML:
#Html.DropDownList("SingleCustomer", String.Empty)
Actually i think u misunderstood the Use of FirstOrDefault. The Following Example il explain the use of FirstOrDefault
var list = new List<string>() { "cus1", "Cus2", "cus3" };
Console.WriteLine(list.FirstOrDefault());
OutPut:
cus1
It il take First value only.
If u checked with some condition means, a collection is empty, it returns the default value for the type.so it eliminates exceptions.
So Whatever if the checked condition is true or false you il get only one Customer value ,for displaying that value dont try dropdown list .dropdown list is used to display More then one Customers.Go for Textbox or Label .
I search through the net but i didn't find any solution,
My problem is that how do I now during update that if a row values has changed or not
or if a row is affected?
use affected_rows();
$this->db->affected_rows()
Displays the number of affected rows, when doing "write" type queries (insert, update, etc.).
When we are working with CodeIgniter, the data is only updated when there is some change in the input field's value and then the $this->db->affected_rows() will return a value greater than 0.
Suppose we have two fields, 'name' and 'email'. If we try to submit the form without changing any of the field, then $this->db->affected_rows() will return 0, else it will return 1.
A better approach is to use:
if ($this->db->affected_rows() >= 0) {
return true; // your code
} else {
return false: // your code
}
I think this is the simplest way to achieve this goal.
return ($this->db->affected_rows() != 1) ? false : true;
private string FindTaxItemLocation(string taxItemDescription)
{
if (!templateDS.Tables.Contains(cityStateTaxesTable.TableName))
throw new Exception("The schema dos not include city state employee/employer taxes table");
var cityStateTaxes =
templateDS.Tables[cityStateTaxesTable.TableName].AsEnumerable().FirstOrDefault(
x => x.Field<string>(Fields.Description.Name) == taxItemDescription);//[x.Field<string>(Fields.SteStateCodeKey.Name)]);
if (cityStateTaxes != null)
return cityStateTaxes[Fields.SteStateCodeKey.Name].ToString();
return null;
}
cityStateTaxes is a DataRow, why/how I cannot get the column value inside FirstOrDefault()?
Thanks,
FirstOrDefault() selects the first item in the collection (optionally that satisfies a predicate) or returns null in the case there it is empty (or nothing satisfies the predicate). It will not do projections for you. So if you use it, it can be awkward to access a field of the item since you must include default value checks.
My suggestion is to always project to your desired field(s) first before using FirstOrDefault(), that way you get your field straight without needing to perform the check.
var cityStateTaxes = templateDS.Tables[cityStateTaxesTable.TableName]
.AsEnumerable()
.Where(row => row.Field<string>(Fields.Description.Name) == taxItemDescription) // filter the rows
.Select(row => row.Field<string>(Fields.SteStateCodeKey.Name)) // project to your field
.FirstOrDefault(); // you now have your property (or the default value)
return cityStateTaxes;