To close or not to close connection in database

后端 未结 7 1008
名媛妹妹
名媛妹妹 2021-01-17 21:15

I work with Windows-Mobile and Windows-CE using SqlCE and I dont know what better to do.

To open connection when the program open, run any

7条回答
  •  一整个雨季
    2021-01-17 21:30

    There are already some conflicting answers here.

    To be honest, I'm not enirely sure how WinCE deals with connections. I don't think there is a ConnectionPool.

    But the general pattern in .NET is to keep connections open as short as possible. This improves reliability and prevents resource leaks. Make sure you know about the using (var conn = ...) { ... } pattern.

    So I would say: go with your second option, and only keep connections longer if you really experience a performance problem, and if opening the connection is the cause. I don't think it will be with SqlCE

提交回复
热议问题