exception
-
Object cannot be cast from DBNull to other types. code is flag = System.Convert.ToInt32(ord["flag"]); i have declared it as int and it can be null in table. can any body give solution for this..... quickly.......
use
int flag = (ord["flag"] == DBNull.Value ? default(int) : ord["flag"]);
please replace the datatype of flag indefault(int)
to the data type of flagAbhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
Create .NET Templates -
use
int flag = (ord["flag"] == DBNull.Value ? default(int) : ord["flag"]);
please replace the datatype of flag indefault(int)
to the data type of flagAbhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
Create .NET Templates -
yah.. need to cast means Convert.ToInt32(ord["flag"]) Now It will work.:rose:
Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
Create .NET Templates -
Object cannot be cast from DBNull to other types. code is flag = System.Convert.ToInt32(ord["flag"]); i have declared it as int and it can be null in table. can any body give solution for this..... quickly.......
here you have declare the variable as nullable. int try it.