Quick tip on how to handle NULL in ADO.net
If you're an old ADO programmer, you may be frustrated by not knowing exactly how to check for NULL. Here's a 1 second tip on how to do it in ADO.NET.
AI
Podsumowanie AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Kod źródłowy
<p>If you try the old fashioned way of checking for null:</p> <p> If IsNull(rsCompany("Name")) Then</p> <p>Visual Studio will tell you that IsNull is not supported and to use DBNull instead. At first I thought this was really nice. However, when I tried to do:</p> <p> If rscompany("Name") = DBNull Then</p> <p>I got an error about assignments not allowed to a type! What was I to do?</p> <p>The Visual Studio help was its usual cryptic self ("The DBNull class is for handling NULL values"...accurate by not alot of help). After some fumbling around, I stumbled on the answer, and thought I'd share it to hopefully save someone 5 minutes of having to research it:<br> <br> If rsCompany("Name") is DBNull.Value then</p> <p>Hope this saves you some time!</p> <p> </p>
Oryginalne komentarze (3)
Odzyskane z Wayback Machine