Questions tagged [sqlconnection.close]

10 questions
11
votes
2 answers

Does SqlDataAdapter close the SqlConnection after Fill() function?

Does SqlDataAdapter close the SqlConnection after the Fill() function or do I need close it myself? string cnStr = @"Data Source=TEST;Initial Catalog=Suite;Persist Security Info=True;User ID=app;Password=Immmmmm"; cn = new…
Wachburn
  • 2,842
  • 5
  • 36
  • 59
8
votes
6 answers

What disadvantages are there for leaving an SQL Connection open?

This seems to be a simple question, but I wonder the disadvantages of not calling the "close()" function.
stckvrflw
  • 1,489
  • 3
  • 22
  • 37
4
votes
3 answers

Opening SqlConnection that has been closed already

Are there any problems with closing and opening of the same SqlConnection object instead of creating new one each time? For example: SqlConnection conn = new SqlConnection(ConnectionString); conn.Open(); //Some work here conn.Close() //Some work…
Aloraman
  • 1,389
  • 1
  • 21
  • 32
2
votes
1 answer

How to validate dataSource name and PortNumber in Connection String of SqlConnection

Please tell how to validate dataSource name and PortNumber in Connection String of SqlConnection. Connection state changes to Open, even I donot give any value for dataSource. Like the code below.. var Connection = new SqlConnection("Data…
Dinesh Kumar P
  • 1,128
  • 2
  • 18
  • 32
1
vote
2 answers

Application Crash on SQL Connection.Close method

I have a windows services which is performing lot of Data processing. At some point, my service is crashed on closing a SQLConnection. When I comment the Close connection method call, Service is working consistently without crashing. What could be…
0
votes
2 answers

How to list opened sql server connections and close the specific one

We have a remote SQL server and c# ERP client programs that use it. Sometimes people are opening the program and forget to close it. In that situation, their SQL connections are staying opened and I won't be able to do some operations. Yes, I can do…
0
votes
6 answers

Importance of closing SQLConnection objects when using the SQLDataReader object

My present contract engagement is at a large E-Commerce company. Their code base which has origins going back to .Net 1.0 has caught me by surprise to contain many issues that raise the level of smell beyond the last crap I took. That…
JohnL
  • 373
  • 1
  • 5
  • 15
0
votes
0 answers

Entity Framework SQL Connections are not getting closed or disposed

I'm using Entity Framework with Repository Pattern, but we have requirement to call stored proecedure, so we ended up in creating DAL Class with EF DBContext has local private variable in DAL Class, private context; I try to instantiate …
0
votes
3 answers

How To Implement Connection In Java by using DriverManager

Hello can any one tell me how to use connection pooling concept i am having normal java methods in which i am using DriverManager() and getConnection(). methods to connect to Database i am creating new connection foe every call and i am closing it…
Prakash
  • 11
  • 1
  • 1
  • 4
-1
votes
1 answer

use a public sql connection or create a connection where is needed?

in a medium application in asp mvc or windows C# which way is betters: 1- create a public sql connection and use in whole of project? 2- create a new sql connection where is needed? note: 1- in the ado.net or ef. 2- use of transaction usual. thanks…