質問

いることもできるでしょう近のOledbDataReaderのオブジェクトのデータを読み込むからです。こちらは該当コード

Dim conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxxxxxxx;")

conSyBase.Open()

Dim cmdSyBase As New OleDb.OleDbCommand("MySQLStatement", conSyBase)
Dim drSyBase As OleDb.OleDbDataReader = cmdSyBase.ExecuteReader

Try

    While drSyBase.Read
     /*Do some stuff with the data here */

    End While

Catch ex As Exception

    NotifyError(ex, "Read failed.")

End Try

drSyBase.Close() /* CODE HANGS HERE */
conSyBase.Close()
drSyBase.Dispose()
cmdSyBase.Dispose()
conSyBase.Dispose()

のコンソール-アプリケーションで話をするようにしていあります。開閉接続れは問題ではありませんが、そこでは誰でもそのアイデアのために何をする希薄化の原因なのでしょうか?

役に立ちましたか?

解決

の答えを見つけたのだ!

drSyBase.Close()

してしまわない場合はキャンセル方法は、コマンドオブジェクト

cmdSyBase.Cancel()

この特有である場合がありSybaseデータベース

他のヒント

このショットが左右にずらしてみてください。あります。Dispose()ラインは、最後にブロックに挑戦しました。このように:


Dim conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxxxxxxx;")
conSyBase.Open()
Dim cmdSyBase As New OleDb.OleDbCommand("MySQLStatement", conSyBase)
Dim drSyBase As OleDb.OleDbDataReader = cmdSyBase.ExecuteReader
Try
  While drSyBase.Read
   /*Do some stuff with the data here */
  End While
Catch ex As Exception 
  NotifyError(ex, "Read failed.")
Finally
  drSyBase.Close() 
  conSyBase.Close()
  drSyBase.Dispose()
  cmdSyBase.Dispose()
  conSyBase.Dispose()
End Try

微力ですが、応援させていただきてから、使用VB.NETものの、最も安全で扱う時にこのクライアントまで、フルのC#での利用"を使用"です。

このように 暗黙のtry-catch やされる可能性があるためです。全てのリソースが中止となり、処分場合の"使用"は終了します。

using (OleDb.OleDbConnection connection = new OleDb.OleDbConnection(connectionString)) 
{
    DoDataAccessStuff();
} // Your resource(s) are killed, disposed and all that

更新:このリンク約 使用書VB.NET 2.0, ても役立っています。

Using conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxxxxxxx;"), _
     cmdSyBase As New OleDb.OleDbCommand("MySQLStatement", conSyBase) 

    conSyBase.Open()
    Dim drSyBase As OleDb.OleDbDataReader = cmdSyBase.ExecuteReader

    Try
        While drSyBase.Read()

            '...'

        End While
    Catch ex As Exception
        NotifyError(ex, "Read failed.")
    End Try

    cmdSyBase.Cancel()
End Using
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top