投稿数 - 437, コメント - 59536, トラックバック - 156

using 嵐のネスト回避

using 嵐でネストが深くなったらこのようにして回避できる。

using(SqlConnection connection = new SqlConnection(connectionString))
using(SqlCommand command = new SqlCommand(selectCommandText, connection))
using(SqlDataAdapter adapter = new SqlDataAdapter(command))
{
   ・・・
}

投稿日時 : 2006年10月4日 21:36

フィードバック

# re: using 嵐のネスト回避

こんばんわ!
これって要は最後にconnection、command、adapterとをきっちりと片付けてくれるっつぅ寸法なんですか!へぇぇ。

というかconnectionだけにusingかけてやればいいって考えてしまいます。
それは浅はかですか。そうですか。。。
2006/10/05 0:07 | koka

# re: using 嵐のネスト回避

>というかconnectionだけにusingかけてやればいいって考えてしまいます。

ぶっちゃけるとその通りのようですよ。command と adapter は Dispose する価値のあるリソースはもっていないそうな。
2006/10/05 0:18 | 囚人

# re: using 嵐のネスト回避

CommandにはTransactionがあります。
Rollbackのことも考える必要があるでしょう。
ま、とりあえずやっとこー
2006/10/05 1:07 | 中博俊

# re: using 嵐のネスト回避

>CommandにはTransactionがあります。
>Rollbackのことも考える必要があるでしょう。
>ま、とりあえずやっとこー

その場合は、Connection が行うんじゃなかったでしたっけ?
とりあえずやっとこーは賛成です。
2006/10/05 1:17 | 囚人

# Fail to understand, miss world

Hello all

I agree with you written a very good text. I think that the subject is not completely exhausted. Waiting for more ...
And by the way see the election of Miss World: http://www.missvanilla.eu/miss-asia.html
2010/08/16 15:32 | Heandirrade

# Targi w polsce

I do not see your logic
2010/09/06 10:39 | Targi

コメントの投稿

タイトル
名前
URL
コメント