Click here to Skip to main content
15,892,298 members
Everything / null

Null

null

Great Reads

by Giovanni Scerra
Patterns to prevent null reference exceptions
by Aram Tchekrekjian
More about pattern matching types with a usage example for each type
by ManojKumar19
Update row column with another row column in same table SQL only if it is null.
by ChristianNeumanns
The "absence of a value" is among the most important concepts a type system has to deal with.

Latest Articles

by ChristianNeumanns
The "absence of a value" is among the most important concepts a type system has to deal with.
by Aram Tchekrekjian
More about pattern matching types with a usage example for each type
by Jesus Carroll
In Data Engineering, supporting Data Science, Data Mining and Reporting tasks, it is useful to get only fields that have data. We don't mind nulls values and we are grateful if this field's structure is dynamic. These ones might be a stat in the set of empty's kingdom.
by Oktay Ekincioglu
Exception handling practices like avoiding null values, writing predictable function signatures, avoiding null reference exceptions, etc.

All Articles

Sort by Score

null 

26 Feb 2015 by Giovanni Scerra
Patterns to prevent null reference exceptions
11 Sep 2023 by Aram Tchekrekjian
More about pattern matching types with a usage example for each type
8 Nov 2023 by Gerry Schmitz
To interpolate, you need the "relative position" of the missing point, relative to the "two" points on "either side" of the missing value. In other words, you can't interpolate unless you have at least 2 points to start with, and you know...
17 Aug 2012 by ManojKumar19
Update row column with another row column in same table SQL only if it is null.
22 Aug 2012 by Christian Graus
You said it all. They used to use VB6. They are morons. I am in the same hell, magic values, no use of null, etc. No, they are wrong.
22 Oct 2013 by Sergey Alexandrovich Kryukov
This is a structure, a value type and hence is not nullable. You can make a member or a variable of System.DateType nullable if you use the type System.DateType? instead:System.DateType? myTime = null;//...if (myTime == null) //...Please see:...
2 Dec 2013 by OriginalGriff
The first thing to do is put a breakpoint on the line: StringCollection strCol = table.Script();And look at the table variable - my guess it that it is null, which means that when you try to access any method or property you will get that error.So then, look at why.What is the...
24 Dec 2017 by Thomas Daniels
This is because of a phenomenon called short-circuiting. This means that the right-hand of the && operator will not be evaluated if the result is already decided from the left-hand. 0 == 1 is 0/false. So, it doesn't matter what the right-hand (k++) would evaluate to, the final result is always...
14 Dec 2023 by ChristianNeumanns
The "absence of a value" is among the most important concepts a type system has to deal with.
22 Aug 2012 by Wendelius
In my opinion, no valid reasons exist. The sole purpose of null value is to describe that the is no data or the data is unknown.I could imagine that this has been reasoned because of the indexing, foreign key and constraint related 'issues' but those things can quite easily be tackled with...
22 Aug 2012 by Sergey Alexandrovich Kryukov
A person who uses something like -5000 as a special magic value to conduct "not a value" is a complete idiot and moron. Actually, using VB6 does not have any excuses. The only reason to use it I can see is to sabotage.Here is one of the most difficult issue of your profession: one of your...
12 Jul 2013 by lewax00
You incremented i before checking. Of course the next item is empty, you haven't populated it yet.
2 Dec 2013 by Sergey Alexandrovich Kryukov
It cannot be as described. The line where the exception is thrown (if I can assume it is thrown actually in this line, which is not the 100% proven fact to me) clearly says that left reference-type value on left is assigned to the property value on right. Assigning null to null would not throw...
15 Sep 2016 by CPallini
You never assign a valid value to the COMPort variable.You should do soemthing similar toCOMPort = New SerialPort()' set the various parameters of the serial port hereSee SerialPort Class (System.IO.Ports)[^].
2 Jan 2017 by K-SIS
There is logical error.1. You are Filling in a loop so after every fill it will wipe previous filled data. (Data is replaced not appended.)2. connection is closed in loop so after first iteration the table object will be null.
7 Nov 2018 by OriginalGriff
Don't do it like that! Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead. When you concatenate strings, you cause problems because SQL...
2 Jan 2022 by Luc Pattyn
it looks like bmp is null due to resourceId being zero. And you did not show any code that sets resourceId...
28 Aug 2012 by Aarti Meswania
don't write 'nothing' in first lineor you can write insert query like below,"INSERT INTO SIGN(TYPESIGN_ID) VALUES(" + "null" + ")"Happy Coding!:)
28 Aug 2012 by Ganesh Nikam
hiii,To retrieve the value of a variable of a nullable type, you should first test its HasValue property to confirm that it has a value. If you try to read the value when HasValue is False, Visual Basic throws an InvalidOperationException exception. The following example shows the...
9 Jul 2014 by Stefan_Lang
Just initialize the pointer array with 0 like this:char** test = new char*[256] = {};char* test[256] = {}Note that since the initialization list is empty, it will be padded with 0 automatically. See here[^] for more info.[edit]fixed intialization statement - sadly it won't work with...
11 Jul 2015 by Wendelius
From the code you have provided as far as I can see you don't populate the dataset anywhere. You do set the SQL statement and the connection and so on but I can't find a call to Fill[^] method anywhere. If this is true there's no data fetched from the database thus leaving your data row non...
16 Feb 2016 by Jochen Arndt
Quote:1-am confused now which is better in Cross-Platform Desktop Application ?That can't be answered in general. It depends.Quote:2- any method to make C++ builder support linux ? or am brain washed.Not yet. Maybe in the future. Only Embarcadero can answer this. Quote:3- what is best...
3 Jul 2017 by OriginalGriff
And the reason is either the date formats don't match for whatever reason, so SQL is getting them wrong, or there is no data which falls in the range. Start by not concatenating strings to form SQL commands: use a parameterised query and past the DateTimePicker DateTime values directly instead...
9 Jun 2019 by CHill60
The easiest way to do this is to use UNION[^] but based on other homework questions I've seen recently your tutor may want you to use UNPIVOT[^]
18 Jun 2019 by Santosh kumar Pithani
CREATE TABLE #TEMP ( Id INT ,Tname VARCHAR(100) ,MobileNumber NUMERIC(10) ,OtherMobileNumber NUMERIC(10) ) INSERT INTO #TEMP VALUES (1,'john',9737943110,9865986532) ,(2,'marry',NULL,8765986521) ,(3,'dally',5487986512,NULL) SELECT ROW_NUMBER()OVER(ORDER BY (SELECT 1)) AS ID...
26 Jul 2020 by oronsultan
Hi Guys, I have a sln in .Net which is based on 2 projects: - Wpf application under the name 'Installer' and a class library under the name 'InstallerCore'. - The 'InstallerCore' is responsible for accessing the data base and basically it is...
28 Sep 2020 by Sandeep Mewara
Quote: How to check nothing then assign the value for address1 ? Try with nullable operators: ' Nothing if customers, the first customer, or Orders is Nothing Dim count As Integer? = customers?(0)?.Orders?.Count() is same as: Dim length As...
9 Apr 2021 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
29 Nov 2021 by OriginalGriff
The null checks are there for a reason - to make sure that there is a User, that the user has an Address, and the address includes a State - without these, there is no information to process - and the null return is the way the method tells you...
23 Dec 2023 by OriginalGriff
DBNull is a special type: it represents an "empty value" in database nullable column. When you issue a SELECT request against the database any matching rows that contain an SQL NULL value is returned as an instance of the DBNull Class[^] ...
22 Nov 2011 by Renat Khabibulin
HiI have a search through database. Search works in separate thread. When entity is found I have to show it and some of related data into WPF UI.I use EntityFramework. Main idea of search process is:foreach (var item in _currentEntitySet){ Items.Add(item); ...
22 Nov 2011 by Sergey Alexandrovich Kryukov
Please see the comment by Mark and my comment to the question.You just need to understand the difference between Invoke and BeginInvoke operations and infer the conclusion by yourself because only you have the whole code. A change from one method to another may change the order of...
22 Aug 2012 by IndifferentDisdain
Our company is interfacing with another software company for a joint project, and we were told that, if a particular value should not be displayed, we should pass in a -5000 (their arbitrary sentinel value); the reason is that no number column in their Oracle database supports null values, on...
12 Oct 2019 by om3n
I want to enter data NULL (rather than numeric numbers, etc.) to the field of type integer. I use the following code:Dim Col2 As Nullable(Of Integer) = NothingOpenDatabase()Command.Connection = ConCommand.CommandType = CommandType.TextCommand.CommandText = "INSERT INTO...
6 Sep 2012 by Dave Kreskowiak
I'll assume that "SystemNull exception" actually means "Object not set to an instance of an object".All you have to do is step through the code where it bombs and check to see which one of your objects returned Nothing. Your code is making the assumption that some call that is supposed to...
17 Jun 2013 by Sergey Alexandrovich Kryukov
You might also mean nullable object, like int?. The answer will be the same: assign the object to some value. How could it possibly be not obvious?—SA
12 Jul 2013 by Member 10153188
Why does my array contain all nulls? System.out.println(loo); -> This will show what's inside the array properlySystem.out.println(tokFix[i]); -> While this will show all null's public static String[] parseFixMsg(String fixMsg1,String fixMsg2){ int i = 0; int...
11 Oct 2013 by ASP.NET Community
 Whenever an attempt is made to access data from the cache, it should be with the assumption that the data might not be there any more. Thus,
11 Oct 2013 by ASP.NET Community
One of the newcomer in C# 4.0 - great newcomer is new keyword 'dynamic'. Dynamic variables are run-time binded which is very helpful many times
11 Oct 2013 by ASP.NET Community
HiThis a common task for Auction bid, events, promotions, project deadline etc.For this sample we need to create a sql table and one stored
13 Oct 2013 by ASP.NET Community
Introduction:         The companies which are offering variety of services to the customers, they need to get the response from the customers in
11 Oct 2013 by ASP.NET Community
NULL can be produce weird results and sometimes it is hard to diagnose the root cause. So to avoid such a problem like this you need to remember few
11 Oct 2013 by ASP.NET Community
 C#protected void Page_Load(object sender, EventArgs e){    // Change the title    Page.Header.Title = "My Content Page Title";        // Change
11 Oct 2013 by ASP.NET Community
Followings are some examples of using SELECT statement. My table name tblTest. Followings are columns. (TestID, TestName, TestDate, TestCity )1)
18 Oct 2013 by Sriram Ramachandran
ASP.NETI've a textbox which should accept null(textbox is empty). But the null value is not inserting in database(sql server). The error is "Input string was not in a correct format". The coding is int BusinessNumber = Convert.ToInt32(txtBusinessNumber.Text);if .ToString() is not working.
18 Oct 2013 by Kenneth Haugland
This could be solved in a number of ways:http://msdn.microsoft.com/en-us/library/f02979c7.aspx[^]or perhaps better in your case:http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx[^]
18 Oct 2013 by phil.o
You have to check whether there is an actual value in your textbox, and if it is convertible to Int32. This way:int BusinessNumber;if (!string.IsNullOrEmpty(txtBusinessNumber.Text) && int.TryParse(txtBusinessNumber.Text, out BusinessNumber)) { // TextBox contains a valid Int32...
22 Oct 2013 by YourAverageCoder
Hi, i want to reset DateTime values for my database in a C# program but it seems DateTime can't be nulled. Any advice on how to do it or if not how to reset the DateTime value? Thanks in advance.
2 Dec 2013 by Cenkay Vergili
An unhandled exception of type 'System.NullReferenceException' occurred in MyProject.exeAdditional information: Object reference not set to an instance of an object.It says , StringCollection strCol is null, but table.Script() is not null(it includes the record.)Here my codelines ...
20 Feb 2014 by slayasty
Hi, I have the following code:public void Sort(){ Collection = (from pricing in Collection orderby pricing.Prices.Price select pricing).ToList();}The problem is I get a null reference error when any of the values in the list is null.It works just fine when all values are...
20 Feb 2014 by Tomas Takac
You can exclude the null values like this:Collection = ( from pricing in Collection where pricing != null && pricing.Prices != null orderby pricing.Prices.Price select pricing).ToList();
6 Jul 2014 by Abdallah Al-Dalleh
Hello allI have the following array of character pointerschar** test = new char*[256];Now this array is passed to a function that fills "some" of its locations. My questions is how to check the status of other unfilled pointers? Or what is the status of these pointers?for example I...
6 Jul 2014 by BacchusBeale
Here is a sample to test. Access to **test will fail if not initialised (pointing to allocated memory).void CTest::Run(){char** test = new char*[256];FILE *f;fopen_s (&f,"b.txt","w");fprintf(f,"**test: 0x%x\n",test);for(int i=0;i 0x%x\n",i,...
7 Jul 2014 by Abdallah Al-Dalleh
Hello all :DI think it's already handled, it appears that all other unfilled locations in the char** test are given NULL after filling the array so all I had to do is to check if the value is null or not. Thanks all for the help :D
9 Jul 2014 by Keith O. Williams
While debugging a game I was thrown with a System.NullReferenceException Error: Object variable or With block variable not set for the following line of code in bold:Public Sub drawPlayer() drawWorld() If ResourceLib.ImageExists("Player_" + wGrid(PlayerPos.X, PlayerPos.Y).TileName) =...
9 Jul 2014 by DamithSL
You need to debug and find which is null at run time. read Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^] if you need more information about debugging. after you found the object which is null and the inputs which is reason for the generate null value, you can easily find a...
16 Oct 2014 by Węgierski.A
I have an Oracle 11g table with not null column and default value. Not null constraint is enabled, there are no triggers (in dba_triggers) which could to modify inserted value. It's impossible to insert null into this column by insert command from script, but thesame insert from package inserts...
16 Oct 2014 by Maciej Los
Have a look here: Oracle Tip: How to use default values with database columns[^]Quote:You must specify at least one column, but you may use the DEFAULT keyword to allow the default value rather than hard-coding a value, so the following is valid syntax that will create a row with all DEFAULT...
19 Oct 2014 by Węgierski.A
Workaround works ok. But, I am not glad; without workaround it works too. My last test had a silly mistake, error results were erronous too ... May be the table was corrupted. Maybe (another solution) the person, who used my package, do commit after errors.Thx for Jörgen Andersson and Maciej Los
1 Dec 2014 by ShadowedR
A simple example of a C# Application interfacing with the Null Modem Emulator (com0com) driver to allow run time creation and configuration of Virtual Serial Ports
8 May 2015 by jaylisto
i did a page where it shows data from sql database, where it is shown in a gridview. i can now then choose the id to be print or to show image in another tab.my problem is the image data type in column. at it shows no preview icon.the easy way is to set "nulldisplay" with a value "no...
9 May 2015 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
This option is available with ImageField. Property is NullImageURL.Refer - Re: how to set default image in asp.net[^]
5 Aug 2015 by ChrisCreateBoss
I am checking which cells in a column are null or in blank and then retrieving the row Index of the empty cells found.I use this code to find the index:StringBuilder sb = new StringBuilder();foreach(DataGridViewRow row in mainDGV.Rows){ if(row.Cells[0].Value.ToString()...
5 Aug 2015 by sasanka sekhar panda
StringBuilder sb = new StringBuilder();foreach(DataGridViewRow row in mainDGV.Rows){//changed line//Reason:.Tostring() method will throw System.NullReferenceException when it//finds a empty cell. if(!(row.Cells[0].Value is string))//or if(...
9 Nov 2015 by Patrick70__
I have a library which fires events through this code:public delegate void ChangedEventHandler(String currentFunction, String PCDMessage, ePcdEventType pcdEventType, ePcdEvent pcdEvent); public event ChangedEventHandler OnStatusChange;andprotected virtual void RaiseEvent(String...
9 Nov 2015 by phil.o
Can you try:if (OnStatusChange != null) { OnStatusChange.Invoke(strCurrentFunction, strMessage, pcdEventType, pcdEvent);}instead?
9 Nov 2015 by Patrick70__
I found the solution and that is so obvious. Now it's obvious. From the main window I called the library functions and only after those I detach the event from the instance of the class.So if launched without backgroundWorked the execution is serial so first it execute the code and then it...
1 Dec 2015 by Sānyà Sani
i have a function which is taking image path from the gallery and set it in the text view so that i can send it to my other DB_class for insert function. but i am not able to send it As it seem to have problem with my setter or getter functions.. please have a look on the code and LogCat below...
16 Feb 2016 by Richard MacCutchan
These are not programming issues, please read Code Project Quick Answers FAQ[^].
26 Mar 2016 by Sonia Wadji
Quote:I am trying to pass the Id of the image inorder to delete the entry from the listview using a notification. But the value of the delGoalId is showing "null". Help me please.Error: NullPointerException: Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String)' on...
15 Sep 2016 by Member 12292743
Dim withevents COMPort as SerialPortDim comOpen as BooleanPrivate Sub Form1_FormClosed(ByVal sender as object, ByVal e As System.Windows.Forms.FormCLosedEventArgs)Handles Me.FormClosedWith COMPort .POrtName = "COM20" various other propertiesEnd withIf COMPort.IsOpen...
13 Oct 2016 by #realJSOP
Where [order status] is not null
17 Oct 2016 by Karthik_Mahalingam
try thisdt.AsEnumerable().ToList().ForEach(row=> { if (string.IsNullOrWhiteSpace(Convert.ToString(row[0]))) row.Delete(); }); dt.AcceptChanges();
28 Oct 2016 by Harpreet05Kaur
HI,Try the following query.See if it helps: SELECT [Order Status] from [Contacts] where [Order Status] Not NULL or [Order Status] != ''
29 Dec 2016 by Davor Bursac
I am trying to fire event from child form to parent form but it keeps null value. I have a delegate and event declared on child form, and method that checks if event is not null. That method is called on button click and supposed to notify parent form for some action (refreshing grid data on...
29 Dec 2016 by OriginalGriff
You seem to have created this as a very simplified version, which is missing a load of information. It may be that the important parts have been lost in the "condensing" process - certainly that code is not going to work as you describe on it's own!Have a look at this: Transferring information...
3 Jan 2017 by Pradeep Prasanna Ekanayaka
your code is modified.. use thisthis may be work for uconnection.Open(); DataSet dsa1 = new DataSet(); DataTable dt1 = new DataTable(); dsa1.Tables.Add(dt1); OleDbDataAdapter da1 = new OleDbDataAdapter(); for (int i = 0; i
3 Jan 2017 by Wendelius
I'm not sure if I understand the situation correctly, but...As already pointed out, don't close the connection inside the loop, otherwise the second fetch will fail. Also if you constantly replace the datasource of the grid, only the last one is shown, all other fetches are in vain.So...
6 Jan 2017 by Dave Kreskowiak
You do know that you're printing this to the console and not a printer, correct?Apart from that, there is too little information to go on. If this is the code you're actually using to "print" a receipt, you've got huge problems.If not, we need to see the code you're using and what...
12 Jan 2017 by Ramzy Abu elloza
I'm trying to make an android app but I encoutered this error and I don't know what to do and why is it showing from the first place, the app crashes with the following error in the log:E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.ramy.medicare,...
12 Jan 2017 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null -...
26 Jan 2017 by Member 12969402
SELECT [Rank] ,[Priority] ,[% Complete] ,[Project Name] ,[Project Manager] ,[Assigned To] ,[Category] ,[Impacted Group(s)] ,[Status] ,[Requested Due Date] ,[Requested By] ,[Project Champion] ,[Created] ...
26 Jan 2017 by Member 7870345
Hello: I'm not sure of the meaning of your question. But if the question is how to change the output of your query from null to "blank", you can use coalesce function. Assuming that "project name" is a string and "% complete" is numeric the query will be:select...
24 Mar 2017 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null -...
3 Jul 2017 by Member 9983063
Hello Guys am select a data from database and second time when i select data from with where clause dt1 so i get return null values am not getting any error but it's return me null values What I have tried: con_string.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0;Data Source...
3 Jul 2017 by Bryian Tan
Part of this query could be the issue. The code have double curly brackets instead of one. FROM Total Where [Date] between #{{0}}# AND #{{1}}# AND [column2] It should be FROM Total Where [Date] between #{0}# AND #{1}# AND [column2]
13 Sep 2017 by WhatsYourIdea
I have a TabActivity and there are 3 tabs in it. In one of the 3 tabs, there is a Button, and I want the button to do something. But where ever I put the EventListener, it just doesn't work. It gives me a NullPointerException. What I have tried: I have tried to put the EventListener in the ...
20 Oct 2017 by Member 9983063
Hello Guys, I am facing an issue that is I get value null from DB I have values in my DB but in my form when I select so I get null please help me how can I do it What I have tried: con_string.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0;Data Source...
20 Oct 2017 by PIEBALDconsult
Just off the top of my head; something like this might serve you better. con_string.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0;Data Source =|DataDirectory|\Restaurant.accdb;Persist Security Info=False"; con_string.Open(); System.Data.IDbCommand cmd = con_string.CreateCommand()...
24 Dec 2017 by Richard MacCutchan
Read and learn: C++ Built-in Operators, Precedence and Associativity[^]
7 Jan 2018 by Maciej Los
A common reason of above error is described here: System.ArgumentNullException: Value cannot be null.[^]
14 Jan 2018 by Member 13621621
So I recently started coding again, and this forum has been MORE then helpful to me thus far. Anyways, I'm working on a simple form that snags a JSON String from a Web API and Deserializes it into a list box. However, any string that returns ANY null value errors out. I know this is a simple...
14 Jan 2018 by Graeme_Grant
The problem is that you're not mapping the JSON properties to the C# class properties correctly. This is why you are getting the error. Please look at Issues deserializing json in C# - Solution 1[^] to correctly map them.
2 Aug 2018 by kijisky
I had the same problem with this provider. Unability of archiver to start was the cause of error. My solution was to increase db_recovery_file_dest_size. Oracle not sending some parameters (named "AUTH_SC_*") during "handshake" if archiver is not working while database is in archivelog mode....
2 Sep 2018 by Member 13933681
i have several property in my class that after adding a new property and doing code first migration , the new added fields have null value in Previous records in database , does anybody have any idea about how to set value to them ??? What I have tried: ...
5 Sep 2018 by OriginalGriff
Ignore ing the problem you have noticed for a moment ... you have bigger ones you arent; aware of. Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries...
8 Nov 2018 by W Balboos, GHB
TMP_LAHIR = "NULL" There's a world of difference between "NULL" and NULL. The first one is a sting of characters, just like "OOPS". The second one is a defined value in, for example, SQL Server. The way you implement the query statement, you wrap the value in single quotes whether it's real...
12 Nov 2018 by TheBigBearNow
Hello I have a question about creating an insert query. Is there a way I can do Convert.DBNull with an int and a datetime? Also I would like to know the most efficient way I should be doing CRUD with C# WPF. I am currently using a listview to view my data from my DB I use a SqlCommand and a...
12 Nov 2018 by Gerry Schmitz
Yes; start using an ORM. I use Entity Framework.
28 Jan 2019 by Patrice T
string query = "UPDATE MASTER_DOSEN SET NIP = '" + NIP + "', NIDN = '" + NIDN + "', GELAR_DEPAN = '" + GELAR_DEPAN + "', NAMA = '" + NAMA + "', GELAR_BELAKANG = '" + GELAR_BELAKANG + "', HOMEBASE = '" + HOMEBASE ...