[問題] bind SqlDataReader to GridView ?

看板C_Sharp作者 (我在新竹找工作中)時間17年前 (2008/08/27 09:05), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
我想問 我想顯示資料庫的資料在網頁上 基本上我是這樣做 pseudocode new SqlConnection() connection.open() connection.createCommand() new SqlDataReader() = connection.executeReader() 然後可以bind return回來的datareader給gridview 然後再close reader, close connection 但我想說做一個method, return一個data回來 這個method本身會close reader和connection. 就是把順序倒過來 然後再把data用gridview之類的顯示出來 不知道有沒有辦法這樣做呢? 因為想說這樣可以避免我做出一個會open connection的method 但有人用完之後忘記close 謝謝大家 -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.52.124
文章代碼(AID): #18jAX0qH (C_Sharp)
文章代碼(AID): #18jAX0qH (C_Sharp)