When I pause my application and then resume after a while, I get this error message:
System.IO.IOException: Unable to read data from the transport connection. Connection reset by peer ---> system.net.sockets.....
I've assigned a class which defines all my objects inside my activity example:
public class Connection: Activity
{
protected SqlConnection con;
protected string MyIp;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var prefs = Application.Context.GetSharedPreferences("Preferences", FileCreationMode.Private);
MyIp = prefs.GetString("IpAdress", null);
con = new SqlConnection("Data Source = " + MyIp + "; Initial Catalog = WiOrder; user id = admin; password = 1234;Connection Timeout=5");
}
}
Here is how I call this class inside activity:
public class Main : Connection
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
//Rest of my code
con.Open();
SqlCommand cmd = new SqlCommand (//query,con);
//.........
}
}