在DataSet中實現參數查詢的方法入門5

來源:互聯網
上載者:User

在上一篇製造自己的查詢方法中輸入SQL語句時加這麼一句

where 會員名=@會員名,後面的一句是一個參數名稱,有點像類裡面的set{this.什麼值=value;},

定義好名稱就可以輸入一個參數來進行查詢

private static void 顯示指定會員名的記錄()        {            會員資料TableAdapter adapter = new 會員資料TableAdapter();            強型別資料集.會員資料.會員資料DataTable data = adapter.GetDataBy會員名("admin");            string output = string.Format("你要顯示的密碼是:{0},年齡是{1}", data[0].密碼,data[0].年齡);            Console.WriteLine(output);        }顯示結果為:

對照一下資料庫中的紀錄

參照這些方法你還可以產生自己的update,delete以及insert方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.