Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null Value

Status
Not open for further replies.

tek1ket

MIS
Jan 25, 2009
70
IR
i have a field in datareader which is has null in it.
i want to check wehterh is it null or not
if (Fdr["Kssc"] != DBNull.Value)
gives me error
so i tried
if (Fdr["Kssc"] != null)
again the same error
what should use to see whether the field is null or not?
 
You could use the IsDBNull() method of your DataReader.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
you shouldn't spend too much time within a datareader. these should be opened, closed, disposed. load the data into a datatable and dispose of the reader. then minipulate the datatable as needed.
Code:
var table = new DataTable();
using(var command = connection.CreateCommand())
{
     //configure command
     table.Load(command.ExecuteReader());
}
return table;

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top