dataset
-
how to find out a null or blank value within a dataset in asp.net/vb.net
-
how to find out a null or blank value within a dataset in asp.net/vb.net
-
what do you mean? dataset is null? Table is null? Row is null? column is null? Or 1 cell is null? "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
-
This is C#, don't know how to do it in VB.NET 1:
foreach(DataRow row in yourdataset.Tables[0].Rows){ if(row[index] == null){ //index can be a number or string } //end if } //end foreach
2:if(yourdataset.Tables[0].Rows[index].ItemArray[index] == null){ } //end if
Note that you have to know which index to use, especially if you have more then 1 table. hope this helps... "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix -
This is C#, don't know how to do it in VB.NET 1:
foreach(DataRow row in yourdataset.Tables[0].Rows){ if(row[index] == null){ //index can be a number or string } //end if } //end foreach
2:if(yourdataset.Tables[0].Rows[index].ItemArray[index] == null){ } //end if
Note that you have to know which index to use, especially if you have more then 1 table. hope this helps... "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix>if(yourdataset.Tables[0].Rows[index].ItemArray[index] == null){ > >} //end if this only checks if the object is null, not if the database field value is null. You have to compare the value to system.dbnull.value: if(yourdataset.Tables[0].Rows[index].ItemArray[index] == DBNull.Value){ } //end if In VB.Net: If yourdataset.Tables[0].Rows[index].ItemArray[index] = DBNull.Value Then 'Do something special Else 'Do your regular thing End If
-
>if(yourdataset.Tables[0].Rows[index].ItemArray[index] == null){ > >} //end if this only checks if the object is null, not if the database field value is null. You have to compare the value to system.dbnull.value: if(yourdataset.Tables[0].Rows[index].ItemArray[index] == DBNull.Value){ } //end if In VB.Net: If yourdataset.Tables[0].Rows[index].ItemArray[index] = DBNull.Value Then 'Do something special Else 'Do your regular thing End If
To be honoust I don't really understand? The
yourdataset.Tables[0].Rows[index].ItemArray[index]
has some value. It's this value that is compared with null, no? If I'm wrong can you point me out the difference ? tnx. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix -
To be honoust I don't really understand? The
yourdataset.Tables[0].Rows[index].ItemArray[index]
has some value. It's this value that is compared with null, no? If I'm wrong can you point me out the difference ? tnx. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrixnull means that the object does not reference an instance of any object. When you declare a variable, but have not set a value to it, it is null. When you query a database, you get back the values stored in the columns you requested. The column exists (or you would get an error), so the Item is not null; it references an object representing the value of the database column for that DataRow. The .net framework provides a special value (System.DBNull) that you can use to see if the value of the Item is Null in the database.