daa*_*daa 5 .net c# xamarin.android xamarin xamarin.forms
当我暂停我的应用程序然后在一段时间后恢复时,我收到以下错误消息:
System.IO.IOException: 无法从传输连接读取数据。对等方重置连接 ---> system.net.sockets .....
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");
}
}
Run Code Online (Sandbox Code Playgroud)
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);
//.........
}
}
Run Code Online (Sandbox Code Playgroud)