Basically I opened a connection and leave it open forever which normally
works fine. Before using the connection each time I checked the connection
state and if it is anything besides open I closed the connection and
reopened it.
What I would like to do assuming the connection is fetching or in error
would be to reset the connection instead of closing it.
public bool CheckConnection()
{
.... other code
switch (_Connection.State)
{
case System.Data.ConnectionState.Closed:
if (this.OnError != null)
this.OnError("Opening SQL"); ;
this._Connection.Open();
return true; ;
case System.Data.ConnectionState.Broken:
case System.Data.ConnectionState.Connecting:
case System.Data.ConnectionState.Fetching:
case System.Data.ConnectionState.Executing:
this.OnError("Closing SQL");
this._Connection.Close();
System.Threading.Thread.Sleep(TimeSpan.FromSeconds (1));
cnt++;
break;
case System.Data.ConnectionState.Open:
return true;
}
.... error handling
return false;
}
Regards,
John
"WhiteWizard" <Wh*********@discussions.microsoft.comwrote in message
news:BC**********************************@microsof t.com...
John,
You're going to have to provide a couple more details. Like, are you
trying
to use the same parameters? Working on the database but different tables?
Can you give us a better idea of what you're trying to accomplish?
AFAIK their is no "reset" function, but you can mitigate the overhead of
recreating the SqlConnection by just closing but not disposing it between
uses.
HTH
WhiteWizard(aka Gandalf)
MCSD.NET, MCAD, MCT
"John J. Hughes II" wrote:
>Is there a way of resetting the SqlConnection with closing/opening it
again.
I am not seeing anything called reset.
Regards,
John