0

Hey guys,


I have an application that connects to DB that is on a remote PC.
Problem is after a couple of minutes or so, it starts throwing exception.

1. The specified network name is no longer available.
2. Connection was forcibly closed by remote host.
3. connection was closed by software on the remote machine.


I couldn't find any solution for these problems.
Please help me with this one.

Thanks and regards
ajinkya

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by abelLazm
0

Are you using the connection the entire time?
What is the database connection timeout set to on both the client and the server?
What code are you using to access the database?
Do you check the connection to see if it is open before you use it?

0

@Momerath,


Yes. I am using connection entire time.
I am trying to connect to sql server 2005.
Here's the code i am using to connect to the database.

try
            {
                
                string strr = "Server=server name;Data Source=xxx.xxx.x.x;Network Library=DBMSSOCN;Initial Catalog=MIS;Connect Timeout=10000;User ID=sa;Password=";
                SqlConnection con1 = new SqlConnection(strr);
                con1.Open();

                if (con1.State.Equals(ConnectionState.Open))
                {
                    MessageBox.Show("Connection Established");
                }
                con1.Close();
            }
                
            catch (Exception)
            {
                MessageBox.Show("Could not establish connection to server");
            }
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.