I have a web service (hosted on IIS) that insert data to database(Xampp)
[WebMethod]
public void Insert(int a)
{
string query = "INSERT INTO result (A) VALUES('" + a + "')";
if (this.OpenConnection())
{
MySqlCommand cmd = new MySqlCommand(query, connection);
cmd.ExecuteNonQuery();
this.CloseConnection();
}
}
The first time I consume this web service it works charm, but for the second time when it tries consume this service again, it returns an error message
“The operation has timed out”
on my coding
s1.Insert(a);
The Web service works correctly again when I restart my web service in IIS, but it is not going to work as it has to work continuously. Any hopes?
The problem I can see could be your this object that remains for second call but it could not open connection.
Make object of your class instead of using this.
e.g