【发布时间】:2015-03-31 10:17:33
【问题描述】:
我的控制器显示错误请解决显示错误无法将列表转换为字符串
public JsonResult GetProperty_id(int selectedValue)
{
List < string > properties = new List < string > ().ToList();
// Property model1 = new Property();
SqlConnection con = new SqlConnection("Server=miracle\\SQLExpress; database=CRUIdb; user id=sa; password=dotnet");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT property_id FROM Service_Property WHERE service_id =" + selectedValue, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
properties = (ds.Tables[0].Rows[0]["property_id"]); //error cannot covert
}
return Json(properties, JsonRequestBehavior.AllowGet);
}
【问题讨论】:
-
@Jenish Rabadiya 你能看看这个问题吗? stackoverflow.com/questions/43122189/…
-
@Arsal 不是我发起了这个话题。我刚刚编辑了问题以使其更具可读性。
标签: c#