1. Is it (null == something) or (something == null)? - .Net Framework
2. How to check if something is Null
VB.Net 2003, Web Application Hey there, ive looked around for ages and havnt found a straight answer. All I want to do is find out if a field in my datatable is Null For example If ts.Rows(isel).Item(4) = Null Then Do something End if but have no idea how to do it.. any help would be great
3. ASPX page jscript rt error: null is null or not an object - Asp.Net
4. VB.NET Null to SQL Null (ASP.NET 2.0 GridView)
Hey, I have everything working now except for this. I have some fields that I am getting data from, then I am sending them to a SQL database. Now the empty string and VB.NET null are different than the SQL Null (type: "System.DBNull"). So, i need some way of cenverting the values into a "System.DBNull" object and then send them to the database. Any ideas? BTW: The parameter called: "ConvertEmptyStringToNull" does not work. Microsoft said there is a bug and it will be fixed for the release date. Thanks, Kivak Wolf
5. I am having huge problems with a null referance - Asp.Net
In Java, creating a class that represents a tuple in a database is relatively simple because if you have a field for, lets say, "Quantity" that is an integer, you can set it to null. Since .NET uses a stack for these Value Types, the integer (Int32) has an initial value of 0 and you can't set it to null. So, what's the best way to approach this without having to jump through a bunch of programmatic hoops? These are a couple of ways I've though of. 1) Create a constant that represents a null Int32, et and use that value (problem: you'd have to constantly check that value if you're doing calculations) 2) Make all of your properties be objects. That way you could set the property to an integer, or a null (or DBNull.Value). (problem: performance hit from boxing and potential errors when doing calculations) 3) Have a property for the field and then have an ancillary property names "FieldXIsNull" (problem: classes get bulky and you end up having to check the IsNull constantly) So, what are the best ways to approach this? Side Note, I'd like to stay away from using datasets because they're big memory hogs. If I can have a class that I can instantiate that keeps track of real values, I'll get better memory usage. As far as the overhead of coding all of these classes, I can use/create code generators for that.
7. How to find out which ref-Variable is null, when exception is null reference - .Net Framework
8. Linq weirdness (improperly trying Column = Null instead of Column IS NULL)
Hi,
I have a wierd problem with Linq. I have the following code in my
fetch method:
/// <summary>Loads the list.</summary>
/// <param name="documentHistoryId">The document
/// for which to get items.</param>
/// <param name="db">The connection to use.</param>
/// <param name="taxRate">The tax rate items
/// should use when loading.</param>
private void LoadSelf(
int documentHistoryId,
decimal? taxRate,
MedDataDataContext db
) {
var items =
from lineitems in db.LineItemHistory
where lineitems.DocumentHistoryId == documentHistoryId
&&
lineitems.ParentLineItemId == null
orderby lineitems.Position
select lineitems;
IsReadOnly = false;
foreach ( var item in items ) {
LineItemRevision lineRev =
LineItemRevision.GetItem( item, 0, taxRate, db );
Add( lineRev );
if ( LoadChildren(
documentHistoryId,
item.LineItemId.Value,
0,
taxRate,
db
) ) {
lineRev.IsGroupStart = true;
}
}
IsReadOnly = true;
}
/// <summary>Loads the list.</summary>
/// <param name="documentHistoryId">The document
/// for which to get items.</param>
/// <param name="db">The connection to use.</param>
/// <param name="taxRate">The tax rate items
/// should use when loading.</param>
/// <param name="parentLineItemId">The id of
/// the parent for items to load.</param>
/// <param name="depth">The depth of the items
/// being loaded.</param>
private bool LoadChildren(
int documentHistoryId,
int parentLineItemId,
int depth,
decimal? taxRate,
MedDataDataContext db
) {
int childCount;
var items =
from lineitems in db.LineItemHistory
where lineitems.DocumentHistoryId == documentHistoryId
&&
lineitems.ParentLineItemId == parentLineItemId
orderby lineitems.Position
select lineitems;
childCount = 0;
depth += 1;
foreach ( var item in items ) {
LineItemRevision lineRev;
childCount += 1;
lineRev = LineItemRevision.GetItem( item, depth,
taxRate, db );
Add( lineRev );
if ( LoadChildren(
documentHistoryId,
item.LineItemId.Value,
depth,
taxRate,
db
) ) {
lineRev.IsGroupStart = true;
}
}
return childCount > 0;
}
So, you notice that the queries are identical in both LoadSelf and
LoadChildren. It seems natural that I make LoadSelf simplier by
changing it to this:
private void LoadSelf(
int documentHistoryId,
decimal? taxRate,
MedDataDataContext db
) {
IsReadOnly = false;
LoadChildren(
documentHistoryId,
null
-1,
taxRate,
db
);
IsReadOnly = true;
}
And I make LoadChildren take a Int32? instead of just an Int32. For
some reason, making these chagnes causes linq to mess up the query.
Instead of specifying ParentLineItemId IS NULL, it tries
ParentLineItemId = Null, which of course never works.
Any ideas?