第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在 C# 函數(shù)中返回 ADO.NET 中的計(jì)數(shù)值?

如何在 C# 函數(shù)中返回 ADO.NET 中的計(jì)數(shù)值?

我在 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;    }
查看完整描述

1 回答

?
收到一只叮咚

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊

我建議聲明一個(gè)像打擊這樣的變量然后添加到它的列表中。


foreach (DataRow dr in dt.Rows)

 {

          var emp=new MyEmployee

            {

                CountId = Convert.ToInt32(dr["CountId"])

            });  

          list.Add(emp);

 }


查看完整回答
反對(duì) 回復(fù) 2021-10-23
  • 1 回答
  • 0 關(guān)注
  • 182 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)