none
need to close the connection/LINQ RRS feed

  • Question

  • in a LINQ to sql select querry
    i am opening a databse connection manully
     like
    DataBaseObject.Connection.Open()
    So
    do i need to close the connection?
    • Moved by VMazur Tuesday, October 20, 2009 10:13 AM (From:ADO.NET DataSet)
    Monday, October 19, 2009 12:00 PM

Answers

  • Hi sujithu,

    Generally speaking, you don't have to care too much  about the manipulation of database connection as LINQ to SQL is designed to simplify the database access for quick development. However, if you open a database connection in the DataContext for some reason, I suggest that you close it once you can. The reason is that, even though the connection can be closed automatically, it might not be closed in time if you don't close it manually. So you can avoid problems if you close the connection manually after you open it by hand.


    Best regards,
    Charlie Lee

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Zhipeng Lee Monday, October 26, 2009 1:51 AM
    Wednesday, October 21, 2009 6:32 AM