Click here to Skip to main content
15,922,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am working with C# windows application, need to connect MS SQL server and use SPs. But I'm getting "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." error. This error getting on remote system's application.
I already specified "command.CommandTimeout = 0;" and Timer is set to 5000; I need to run query / SPs for scheduled time. command is SqlCommand Object. But getting the same.

Please help any one!
Thanks in advance.
Posted
Comments
Padam Agrawal 5-Oct-13 11:04am    
Hello,

As you already tested timeout property with 0 value and its not working for you, so we can observe others things too like,

1. What is the SP execution cast if directly run on MS SQL server?

2. Are you able to use other SPs using project for the same DB?

3. Make sure there is no internet braking issue

4. As CommandObject.CommandTimeout = 0 should work, can you try it again in fresh separate code.

Thanks,

hello

You just put

command.CommandTimeout = 0;

here command is object of sql command


Thanks
Abhimanyu
 
Share this answer
 
C#
try
           {
               objErr = new ErrorLog(FilePath);
               objErr.SaveException("Call to Queued Result Start...");

               byte[] Thb_Templ = new byte[0];
               int PK_ID = 0;
               string Result = string.Empty;
               dsTemp.Clear();

               sqlcon.Open();
               if (sqlcon.State == ConnectionState.Open)
               {
                   sqlcon.Close();
               }
               else if (sqlcon.State == ConnectionState.Closed)
               {
                   sqlcon.Open();
               }
               string qry = "CIS_USP_DedupeStoreSGTemplate";
               sqlcmd = new SqlCommand(qry, sqlcon);
               sqlcmd.CommandType = CommandType.StoredProcedure;
               sqlcmd.Parameters.AddWithValue("@PK_ID", Convert.ToInt32(PK_ID));
               sqlcmd.Parameters.AddWithValue("@Thb_Templ", Thb_Templ);
               sqlcmd.Parameters.AddWithValue("@Result", Result);
               sqlcmd.Parameters.AddWithValue("@Action", "VIEW");

               adap = new SqlDataAdapter(sqlcmd);
               adap.Fill(dsTemp, "SGTemplates");
               sqlcon.Close();
               //ConvertTmplFromSGToISO(dsTemp);
               if (dsTemp.Tables.Count > 0)
               {
                   objErr.SaveException("Convert Queued Result To processing Start...");
                   ConvertDedupeStoreTmplFromSGToISO(dsTemp);
                   objErr.SaveException("Convert Queued Result To processing Ends...");
               }
               objErr.SaveException("Call to Queued Result Ends: ");
           }
           catch (Exception GenExp)
           {
               string FilePath = ConfigurationManager.AppSettings["XmlFilePath"].ToString();
               ErrorLog objErr = new ErrorLog(FilePath);
               objErr.SaveException(GenExp.Message);
           }
 
Share this answer
 

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