Best practice? open and close multi connections, or one large open connection for ado.net

前端 未结 4 1326
一个人的身影
一个人的身影 2021-01-02 00:44

I am using ADO.Net for some database connectivity and I was just hoping I was doing it the right way. I am opening and closing multiple connections for each stored procedur

4条回答
  •  醉话见心
    2021-01-02 01:02

    A better way to do this would be to prep both of the commands and then open the connection and execute them both in quick succession:

    conn.Open();
    comm1.ExecuteReader();
    comm2.ExecuteReader();
    

    Always keep them open for as short a time as possible.

提交回复
热议问题