Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I want to send message on a particular date, While executing given below code showing one error. The error is "operation has time out". Help me to find a proper solution. Thank You.
Code :

C#
private void timer1_Tick(object sender, EventArgs e)
{
FeeMsgTableAdapters.tbl_FeeMessageTableAdapter fm;
fm = new FeeMsgTableAdapters.tbl_FeeMessageTableAdapter();
DataTable dt = new DataTable();
dt = fm.GetDetails();
foreach (DataRow row in dt.Rows)
{
   WebClient client = new WebClient();
   string StudentMob = (row["mobile"].ToString());
   string dueDate = DateTime.Today.AddDays(3).ToShortDateString();
   string FeeMessage = "Test Message";
  string baseurl = "http://www.unicel.in/SendSMS/sendmsg.php?uname=*****&pass=*****&send=****&dest='" + StudentMob + "&msg=" + FeeMessage;
 client.OpenRead(baseurl); // Error popup here
}
}


I have added the following in App.config but it does not look like it helps.

HTML
<httpRuntime maxRequestLength="1048576" executionTimeout="3600"/>


App Config :

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
  <add name="*****" connectionString="Data Source=***;Initial Catalog=**;User   ID=**;Password=****" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <startup> 
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600"/>  
</system.web>
</configuration>
Posted
Updated 15-Feb-15 21:04pm
v4
Comments
ZurdoDev 13-Feb-15 8:22am    
You don't want to use a timer in Web App. Wrong technology.
Member 11042100 16-Feb-15 1:00am    
This is a windows application. And timer is required.
Sergey Alexandrovich Kryukov 16-Feb-15 2:12am    
What is that beast, "ASP.NET Windows form"?
—SA
Member 11042100 16-Feb-15 3:05am    
Sorry. Its a mistake.

1 solution

You should use timeout for your table adapter .To set command timeout go to 'yourdataset.Designer.cs' that holds your FeeMsgTableAdapters defination(Or right click on FeeMsgTableAdapters and Go to Defination that leads you to the code page descussed here ).Then search for public FeeMsgTableAdapters(){this.ClearBeforeFill = true;} --Constructor  .In this constructor just need a little bit modification .


C#
FeeMsgTableAdapters(){

this.ClearBeforeFill = true;
_adapter.SelectCommand.CommandTimeout = 700; //you may set 700 or more .I assume that you only select through table Adpater so I set timeout for SelectCommand only
}

Happy Coding!
 
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