我想問 我想顯示資料庫的資料在網頁上
基本上我是這樣做
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