empty

Not set or empty string -- which is better for if it ends up displaying "none" to the user?

I am wondering if you use unset variables, empty strings (or 0's), or "None" to determine if a variable is "None"? The case I'm thinking of is, I'm retrieving something from the database, but find that the value is not set for the record, usually determined by the fact that there are no records or a null value. This will display to the ...

NULL vs Empty when dealing with user input

Yes, another NULL vs empty string question. I agree with the idea that NULL means not set, while empty string means "a value that is empty". Here's my problem: If the default value for a column is NULL, how do I allow the user to enter that NULL. Let's say a new user is created on a system. There is a first and last name field; last na...

Strange behavior in constructor

Hi, I have a class made up of several fields, and I have several constructors. I also have a constructor that doesn't take any parameters, but when I try to use it: int main { A a; } The compiler generates an error, while if I use it like this: int main { A a(); } It's ok. What's that? Thank you ...

C#, Linq2SQL: Sum() causes exception instead of returning 0 when no rows

I have this code (ok, I don't, but something similar :p) var dogs = Dogs.Select(ø => new Row { Name = ø.Name, WeightOfNiceCats = ø.Owner .Cats .Where(æ => !æ.Annoying) .Sum(æ => æ.Weight), }); Here I go through all dogs and sum up the weight (into a non-null...

How can I detect if a string is empty of characters?

How do I determine if the string has any alpha character or not? In other words, if the string has only spaces in it how do I treat it as an Empty string? ...

How do you write in JavaScript a empty key from JSON?

Hello todos! Let's say you have the following JSON object {"":"some text"} How do you retrieve it in JavaScript? json_in_var={"":"some text"} alert(json_in_var.) I'm perplexed on this one, any help welcome! ...

Empty database in MySQL and PHP?

Is it possible to empty an entire database by connecting to it with PHP and giving a command? ...

.Net: Empty string is not clear space character?

Hi all. I've always use String.IsNullOrEmpty to check for a empty string. It recently come to my attention that a " " count as not a empty string. For example, Dim test As String = " " If String.IsNullOrEmpty(test) Then MessageBox.Show("Empty String") Else MessageBox.Show("Not Emtpy String") End If It wi...

How to check for an Empty Gridview

Hi, I have an ASP.NET 2.0 (C#) web app, and in it I have a gridview that gets its data from an oracle database. I want to know how to check if the gridview is empty, and the do something. I have already tried: if(GridView.Rows.Count == 0) { // Do Something } but it doesn't work... Any ideas? Thank you. ...

PHP: what's an alternative to empty(), where string "0" is not treated as empty?

In PHP, empty() is a great shortcut because it allows you to check whether a variable is defined AND not empty at the same time. What would you use when you don't want "0" (as a string) to be considered empty, but you still want false, null, 0 and "" treated as empty? That is, I'm just wondering if you have your own shortcut for this: ...

size() Vs empty() in vector - why empty() is preferred?

While debugging something, I saw the STL vector::empty() implementation: bool empty() const {return (size() == 0); } I believe, whenever we are probing the emptiness of vector it is always recommended to use empty over size(). But seeing that implementation, I am wondering, what is the benefit of doing so? Instead, there is a fun...

How to quickly check if folder is empty (.NET)?

Hello. I have to check, if directory on disk is empty. It means, that it does not contain any folders/files. I know, that there is a simple method. We get array of FileSystemInfo's and check if count of elements equals to zero. Something like that: public static bool CheckFolderEmpty(string path) { if (string.IsNullOrEmpty(path))...

php isset do you need it in a form check?

Hi, I trying to understand if a isset is required during form processing when i check $_REQUEST["input_name"] if no value is passed it doesn't cry about it and php doesn't throw out an error if you are trying to access a array item which doesn't exist....i can use if($_REQUEST["input_name"]).. what about "empty" even in those cases i can...

Java iterator over an empty collection of a parameterized type

In Java, I need to return an Iterator from my method. My data comes from another object which usually can give me an iterator so I can just return that, but in some circumstances the underlying data is null. For consistency, I want to return an "empty" iterator in that case so my callers don't have to test for null. I wanted to write ...

TabContainer intermitting blank in IE and always empty in Firefox

Hey everyone, I have a tabcontainer with 3 tab panels that sometimes renders blank in IE6/7 and is always empty in Firefox. I looked at the source and it shows the visibility as hidden. I can't for the life of me see why this is happening. I checked Fiddler and Firebug and nothing looks out of the ordinary. All resource files are being...

A concise explanation of nil v. empty v. blank in Ruby on Rails

I find myself repeatedly looking for a clear definition of the differences of nil?, blank?, and empty? in Ruby on Rails. Here's the closest I've come: blank? objects are false, empty, or a whitespace string. For example, "", " ", nil, [], and {} are blank. nil? objects are instances of NilClass. empty? objects are class-specific, and...

Find SQLite Column Names in Empty Table

For kicks I'm writing a "schema documentation" tool that generates a description of the tables and relationships in a database. I'm currently shimming it to work with SQLite. I've managed to extract the names of all the tables in a SQLite database via a query on the sqlite_master table. For each table name, I then fire off a simple s...

How should I test null and/or empty string parameters in a method?

It is common to have classes with methods with string parameters that must be validated agains null or empty, such as this example: public class MyClass { public void MyMethod(string param){ if(string.IsNullOrEmpty(param)){ throw new ArgumentNullException(...); } //... } } It's clear that ...

javascript: how to check if an array element only contains new line?

A plain text file made up of paragraphs and some blank lines is loaded into an array via Ajax. The array is split into elements by new lines, such as: var infoArray = new Array(); infoArray = response.split("\n"); Then the array is put through a for loop, with various tests for keywords in various elements, which indicate the next n-e...

Sharepoint Lists.asmx: The request failed with an empty response.

Hello All, I'm writing a very small app to create and test caml querys for sharepoint. While executing the GetListItems method I'm receiving the following exception; System.Net.WebException: "The request failed with an empty response." The service is located on a https address (ssl). I setup the service as follows; result = new List...