2019年11月4日 星期一
npoi 讀取excel 空值 出錯
if (row != null)
{
for (int j = 0; j < 9; j++) //對工作表每一列 //最好寫數字,不然會出錯
// for (int j = 0; j < row.LastCellNum; j++) //對工作表每一列
{
if (row.GetCell(0).ToString() == null)
{
continue;
}
//解決讀到空值或出錯的問題
if (row.GetCell(j) == null || Convert.IsDBNull(row.GetCell(j)))
{
dr[j] = null;
}
else
{
string cellValue = row.GetCell(j).ToString(); //獲取i行j列資料
dr[j] = cellValue;
}
}
}
{
for (int j = 0; j < 9; j++) //對工作表每一列 //最好寫數字,不然會出錯
// for (int j = 0; j < row.LastCellNum; j++) //對工作表每一列
{
if (row.GetCell(0).ToString() == null)
{
continue;
}
//解決讀到空值或出錯的問題
if (row.GetCell(j) == null || Convert.IsDBNull(row.GetCell(j)))
{
dr[j] = null;
}
else
{
string cellValue = row.GetCell(j).ToString(); //獲取i行j列資料
dr[j] = cellValue;
}
}
}
2019年11月3日 星期日
linq的join語法
https://blog.miniasp.com/post/2010/10/14/LINQ-to-SQL-Query-Tips-INNER-JOIN-and-LEFT-JOIN
left語法確保products資料完整出現
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
select * from [dbo].[AFM_CheckList] c RIGHT join [dbo].[AFM_Product] p
on c.ProductID = p.ProductID
from c in Categories join o in Products on c.CategoryID equals o.CategoryID into ps from o in ps.DefaultIfEmpty() select new { c.CategoryName, o.ProductName }
left語法確保products資料完整出現
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
select * from [dbo].[AFM_CheckList] c RIGHT join [dbo].[AFM_Product] p
on c.ProductID = p.ProductID
2019年11月2日 星期六
在C#中有沒有將時間轉換成純數位類型的方法
DateTime dt = DateTime.Now;
string ds = dt.ToString("yyyyMMddHHmmss");
double dd = Convert.ToDouble(ds);
Label1.Text = dd.ToString();
string ds = dt.ToString("yyyyMMddHHmmss");
double dd = Convert.ToDouble(ds);
Label1.Text = dd.ToString();
2019年11月1日 星期五
linq字串轉數字及數字轉字串
var products =db.AFM_Product.AsEnumerable()
.Where(m=>m.ProductName.Contains(str_Product))
.OrderBy(m => int.Parse(m.ProductID)).ToList();
//需要把productID轉成int來排序時
var query = from Parts in db.AFM_Product.AsEnumerable()
where Parts.UnitPathId==str_UnitPathId
where Parts.ProductName.Contains(str_ProductName)
orderby int.Parse(Parts.ProductID)
select Parts;
訂閱:
文章 (Atom)
WPF聊天室应用(ASP.NET Core SignalR)
WPF聊天室应用(ASP.NET Core SignalR) https://www.bilibili.com/video/BV1Q741187Si?p=2 https://www.bilibili.com/video/BV1UV411e75T?from=search...
-
http://emn178.pixnet.net/blog/post/93557502-%E9%80%A3%E7%B5%90%E4%B8%B2%E5%88%97%28linked-list%29