Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
0 down vote favorite


I have made an application using C#, .Net and SQL Server as a database tool.

Today I run it on a multi-user environment. I hosted SQL Server on server and install the application on client computers. Initially it is working fine but after some time I got an error message. The error is given below.

System.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) ---> System.ComponentModel.Win32Exception (0x80004005): The specified network name is no longer available

I used this code to create the connection string -

C#
class SqlConnDAC
 {
    public static SqlConnection CreateConn()
     {
      SqlConnection con = new SqlConnection(@"Data Source=XXX.XXX.X.XXX\SQLEXPRESS;Initial    Catalog=TrulyDB;User ID=sa;Password=XXXXXXXX");
      return con;
      }
}



And I use the following code to insert data into OCF table-

C#
    public string OCF_EntryDB_Commerce(OCF_BO formDb)
    {
      try
      {
          string intOCF=formDb.OCF_Cont_No;

          SqlConnection con = SqlConnDAC.CreateConn();
          SqlDataAdapter sda = new SqlDataAdapter("select * from OCF_Commerce", con);
          DataSet ds = new DataSet();
          sda.Fill(ds, "OCF_Commerce");
          DataTable dt = ds.Tables["OCF_Commerce"];
          DataRow dr = dt.NewRow();
          dr[0] = formDb.OCF_Cont_No;
          dr[1] = formDb.Customer_Name;
          dr[2] = formDb.Order_Cont_Type;
          dr[3] = formDb.Book_No;
          dr[4] = formDb.Area_To_Be_Served;
          dr[5] = Convert.ToInt32(formDb.No_of_Floor);
          dr[6] = formDb.Type_Of_Premisses;
          dr[7] = formDb.Phone_Number;
          dr[8] = formDb.Email_ID;
          dr[9] = formDb.Adress;
          dr[10] = formDb.Adress_To_be_serverd;
          dr[11] = Convert.ToInt32(formDb.Cont_Value);
          dr[12] = Convert.ToInt32(formDb.Cont_Tax);
          dr[13] = Convert.ToInt32(formDb.Total);
          dr[14] = formDb.Cont_Date;
          dr[15] = formDb.Cont_Month;
          dr[16] = formDb.Cont_Year;
          dr[17] = formDb.Service_Start_Date;
          dr[18] = formDb.Service_Start_Month;
          dr[19] = formDb.Service_Start_Year;
          dr[20] = formDb.Cont_Period_From;
         dr[21] = formDb.Cont_Period_From_MM;
          dr[22] = formDb.Cont_Period_From_YY;
          dr[23] = formDb.Cont_Period_To;
          dr[24] = formDb.Cont_Period_To_MM;
          dr[25] = formDb.Cont_Period_To_YY;
          dr[26] = formDb.TermsOfPayments;
          if (formDb.TypeOfSite == "SingleSite")
          {
             intOCF = formDb.OCF_Cont_No;
          }
          else if (formDb.TypeOfSite == "MultipleSite")
          {
              intOCF = GenerateInt_OCF(formDb.OCF_Cont_No);

          }

          dr[27] = intOCF;
          dr[28] = formDb.OperatingBranch;

          OCF_Int_ID.internalOCF = intOCF;
            dt.Rows.Add(dr);
          SqlCommandBuilder sbil = new SqlCommandBuilder(sda);
          sda.Update(dt);

          return ("\nDone - and internal OCF number for "+formDb.Adress_To_be_serverd+" ="+intOCF+" \n");
     }
}
Posted
Comments
Suvabrata Roy 12-Dec-14 2:40am    
Your error is very clear cut : this a network related issue so you could check it using Ping -t [IP] and check packet is dropping or not

another thing : please close connection after use.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900