null

Microsoft SQL: CASE WHEN vs ISNULL/NULLIF

Besides readability is there any significant benifit to using a CASE WHEN statement vs ISNULL/NULLIF when guarding against a divide by 0 error in SQL? CASE WHEN (BeginningQuantity + BAdjustedQuantity)=0 THEN 0 ELSE EndingQuantity/(BeginningQuantity + BAdjustedQuantity) END vs ISNULL((EndingQuantity)/NULLIF(BeginningQuantity + BAdjus...

Linq ExecuteCommand doesn't understand nulls

I'm having a problem when passing nulls to a ExecuteCommand() method using linq. My code is similar to the one that follows: public void InsertCostumer(string name, int age, string address) { List<object> myList = new List<object>(); myList.Add(name); myList.Add(age); myList.Add(address); ...

Never use Nulls?

We are currently going through the long process of writing some coding standards for C#. I've written a method recently with the signature string GetUserSessionID(int UserID) GetUserSession() returns null in the case that a session is not found for the user. in my calling code... I say... string sessionID = GetUserSessionID(1) if (...

NullReferenceException was unhandled, Object Reference not set to an instance of an object

Hi there, Whenever I run my program, I get: NullReferenceException was unhandled, Object Reference not set to an instance of an object. When I start the program, I have a form appear called MaxScore where the user enters the max score and presses OK. In the OK event, I call a method from MainForm to update the maxGameCountLabel on MainF...

Unable to cast object of type 'System.DBNull' to type 'System.String`

I got the above error in my app. Here is the original code public string GetCustomerNumber(Guid id) { string accountNumber = (string)DBSqlHelperFactory.ExecuteScalar(connectionStringSplendidmyApp, CommandType.StoredProcedure, "GetCustomerNumber", ...

Custom AS3 class is null after being added to Array

I'm a C# developer who is trying to learn some AS3, so this is going to be a pretty newbie question. I'm getting confused with regards to scope and GC, as I have a custom MovieClip-extending class (Slide) which I create instances of within a loop and push() into an Array, but afterwards the items are null when I pull them out of the col...

Oracle - NULLS in foreign keys?

Hi, I'm trying to answer the following question... "Explain the issues that arise when NULLs are present in columns that make up foreign keys. Discuss how ANSI have attempted to resolve this issue with the three 'matching rules' that can be adopted when using concatenated foreign keys." Can anyone point me in the right direction as to...

Session null in ASP.Net MVC Controller Constructors

Hi, Why is Session null in the constructors of Controllers? It can be accessed from Action methods. Presumably, because the MVC Routing framework is responsible for newing-up a Controller, it just hasn't (re-)instantiated the Session at that point. Does anyone know if this is by design and, if so, why? [I have managed to circumvent th...

How to handle Null in LINQ Subquery?

I've got a subquery that returns the most recent value from a child table. In some cases the subquery returns nothing. The query below fails at runtime because the inferred type of MemberPrice is decimal and is not nullable. Simplified query: Dim q = From s In dc.STOCKs _ Select s.ID, MemberPrice = _ (From mp In dc...

How can I bind a combobox field of a databound object to a datasource and still allow nulls?

I have a form databound to a customer object, and one of the fields is a nullable int representing a "type". This is displayed as a combobox, and the combobox is bound to the "Types" table. When a customer with a null type is loaded into the form's datasource, the combo box displays no value, but then upon clicking it you must select a...

Write Conflicts - even with me.dirty

In an application that I am writing, I am getting Write Conflicts when I use VBA code to change the value of a checkbox on a form. I have tried inserting the following code into the events that have VBA changing the values of any object on the form: If Me.Dirty Then Me.Dirty = False End If But the problem persists - as if the rec...

StructureMap controller factory and null controller instance in MVC

I'm still trying to figure things out with StructureMap and one of the issues i'm running into is my Controller Factory class blowing up when a null controller type is passed to it. This only happens when the application builds for the first time, after which every subsequent build works fine. Even when i shutdown Visual Studio and reope...

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 ...

When using Linq, is DbNull equivalent to Null?

This is not about DBNull vs Null. I understand the difference. What I would like to know is if I am using Linq, say to access a User.EmailAddress, then checking User.EmailAddress == null is the same as User.EmailAddress == DBNull correct? My reasoning is that the absence of data in the database results into Linq not generating an objec...

Updates to Records not allowed - Write Conflict

This stems from a previous question I asked - about a write conflict with a form, but the problem seems to be originating from the fact that I can update existing records in a linked table provided by one System DSN, but not another linked table provided by another DSN (different database) - allowing me to enter records at first, but the...

F#: Nullable<T> Support

What is the right way to use Nullable in F#? Currently I'm using this, but it seems awefully messy. let test (left : Nullable<int>) = if left.HasValue then left.Value else 0 Console.WriteLine(test (new System.Nullable<int>())) Console.WriteLine(test (new Nullable<int>(100))) let x = 100 Console.WriteLine(test (new Nullable<int>(x))) ...

F#: Why aren't option types compatible with nullable types?

Why aren't option types like "int option" compatible with nullable types like "Nullable"? I assume there is some semantic reason for the difference, but I can't figure what that is. An option in F# is used when a value may or may not exist. An option has an underlying type and may either hold a value of that type or it may not have ...

Null in Flex ComboBox

How can you make a ComboBox where the user can select null? If you simply create a combobox with null in the dataprovider, the value appears but the user cannot select it: <mx:ComboBox id="cb" dataProvider="{[null, 'foo', 'bar']}" /> Is there a way to make that null selectable? A workaround is to add an item into the dataProvider th...

Asp.net: handle null in a foreach loop

Hi, in a ASP.NET application (MVC) I have a foreach loop that loops through a structure that may contain or not some element: <% foreach (XElement segnalazione in ((XElement)ViewData["collezioneSegnalazioni"]).Elements("dossier")) { %> <tr> <td><%= Html.Encode(segnalazione.Element("NUM_DOSSIER").Val...

determine size of array if passed to function

Is it possible to determine the size of an array if it was passed to another function (size isn't passed)? The array is initialized like int array[] = { XXX } .. I understand that it's not possible to do sizeof since it will return the size of the pointer .. Reason I ask is because I need to run a for loop inside the other function wher...