0
超时已过期。在从池中获取连接之前已超时。出现这种情况可能是因为所有池连接使用,最大池大小达到.net api连接错误
我有这个错误的最大时间我的连接字符串是
我有这个错误
和最大时间我这样的api
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
//string valuess = Commanfunction.logintokencheck(user_id, token);
try
{
//if (valuess == "True")
//{
DataTable dt = new DataTable();
using (SqlCommand cmd = new SqlCommand("SELECT * FROM [nwt].[usermessage] where [to_user] = '" + user_id + "' AND [msg_user_type] ='inbox' AND [reviwe] =1 AND ([status]='active' OR [status]='keep')", sconn))
{
sconn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
string x = "{\"status\":\"200ok\",\"reviewcount\":" + dt.Rows.Count;
// string y= serializer.Serialize(x);
//foreach (DataRow dr in dt.Rows)
//{
// row = new Dictionary<string, object>();
// foreach (DataColumn col in dt.Columns)
// {
// row.Add(col.ColumnName, dr[col]);
// }
// rows.Add(row);
//}
//string z = serializer.Serialize(rows);
return new RawJsonActionResult(x + "}");
//return (x + "\"countries\":" + z + "}");
}
我该如何解决这个错误,并优化我的API。为解决方案
什么是'sconn'?这里缺少很多信息。 –
SqlConnection sconn = new SqlConnection(ConfigurationManager.ConnectionStrings [“ConnString”]。ConnectionString); – rahul