I have an excel file that has the ff. data:
ordNo - ordDate
9 - 2013-10-22
10 - null
11 - 0
12 - 2013-10-23
13 - 2013-10-24
I also have this code below and it also add those who have NULL or 0 ordDate in the orderTable:
using (var trans = DB.db.GetTransaction())
{
ordNo = Convert.ToInt32(DB.db.Insert("dbo.orderTable", "ordNo", new
{
ordNo = data.ordNo,
ordDate = data.ordDate,
}));
trans.Complete();
}
I want to add the ordNo and ordDate in the orderTable but only those who have dates.
How can I do that by uploading an excel file and with the use of asp.net mvc?
I badly need your help guys. Thanks :)
using (var trans = DB.db.GetTransaction())
{
if(data.ordDate!=null)
{
ordNo = Convert.ToInt32(DB.db.Insert("dbo.orderTable", "ordNo", new {ordNo =data.ordNo,ordDate = data.ordDate,}));
}
trans.Complete();
}
If you have string data type as ordDate
, you can add additional condition to check 0
as well
if(!String.IsNullOrWhiteSpace(data.ordDate)
&& data.ordDate.Trim() !="0")
{
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.