- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当我暂停我的应用程序并在一段时间后恢复时,我收到此错误消息:
System.IO.IOException: Unable to read data from the transport connection. Connection reset by peer ---> 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");
}
}
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);
//.........
}
}
最佳答案
我遇到了同样的问题,并且在尝试连接到服务器时(有时)遇到了这个异常。
Unable to read data from the transport connection: Connection reset bypeer.
经过多次搜索,我找到了这个answer
Quote from the answer
This error usually means that the target machine is running, but theservice that you're trying to connect to is not available. (Either itstopped, crashed, or is busy with another request.)
In English: The connection to the machine (remote host/server/PC thatthe service runs at) was made but since the service was not availableon that machine, the machine didn't know what to do with the request.
所以,你应该检查你的网络连接
欲了解更多信息,
关于c# - 错误无法从传输连接读取数据。连接被对端重置。赛马林,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51236025/
SELECT A.horse, A.datum, Sum(IIf([prev_place] = ---)) AS cum_show_ct, count(prev_place) AS cum_race_
我是一名优秀的程序员,十分优秀!