2014年7月3日 星期四

c# Parameters.AddWithValue DBNull

在Inser or Update時難免遇到的問題
第一個想法會寫個function來判斷DBNull 或是文字
或者是用三元運算子
今天看到更短的寫法順便學一下
 
cmd.Parameters.AddWithValue("@abc", (object)item.abc ?? DBNull.Value);
參考網址
點我前往