我在 C# 中創(chuàng)建了 ADO.NET,我想在其中返回計(jì)數(shù)值。我的程序GetAllEmployees @UserId返回員工總數(shù)。但list總是返回1即使CountId顯示0。我正在做一些愚蠢的事情。誰(shuí)能幫幫我嗎。 public List<MyEmployee> GetAll(int UserId) { clsClass cls = new clsClass(); DataSet ds; List<MyEmployee> list = new List<MyEmployee>(); SqlParameter[] prms = new SqlParameter[1]; string sSQL; sSQL = "exec GetAllEmployees @UserId"; prms[0] = new SqlParameter("@UserId", SqlDbType.Int); prms[0].Value = UserId; ds = cls.CommandwithParams(sSQL, prms); DataTable dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { list.Add( new MyEmployee { CountId = Convert.ToInt32(dr["CountId"]) }); } return list; }
如何在 C# 函數(shù)中返回 ADO.NET 中的計(jì)數(shù)值?
30秒到達(dá)戰(zhàn)場(chǎng)
2021-10-23 16:11:48