我有一個(gè)問題,如果返回的值不為空,這會起作用,但是System.NullreferenceException當(dāng)返回為空時(shí)我得到一個(gè)。我嘗試了很多東西,但似乎無法破解它。這里的任何幫助將不勝感激。string HwPlts = "select top 1 plts from (select sum(ISNULL(Heywood_Plts, 0)) as plts, date_Uploaded, time_Uploaded, Upload_ID from InboundRawData Group by date_Uploaded, time_Uploaded, dispatch_Date, Upload_ID having dispatch_Date = @prod_Date) as p order by Upload_ID desc";SqlCommand cmd1001 = new SqlCommand(HwPlts, connection);cmd1001.Parameters.AddWithValue("@prod_Date", dateTimePicker1.Text);HWplt.Text = cmd1001.ExecuteScalar().ToString();
如何處理 Null 值的 ExcuteScalar 異常?
人到中年有點(diǎn)甜
2022-12-04 10:51:40