【发布时间】:2020-09-15 10:09:03
【问题描述】:
列表在 api 中返回。如果数据库中有多个值,我不会收到错误消息。正确返回列表。但是当我得到一个值时,我在使用 api 时会出错。
这是我的代码;
WebService1.asmx
[WebMethod(EnableSession = true)]
public List<AP_City> AA_Send_CountryCode(string us, string ps, string country_code)
{
AP_City menuclass = new AP_City();
List<AP_City> menuliste = new List<AP_City>();
DbClassSQL db = new DbClassSQL();
DataTable dt2x = db.Doldur("SELECT * FROM AP_City where CountyCode='" + country_code + "' order by OrderNumber");
if (dt2x.Rows.Count > 0)
{
for (int i = 0; i < dt2x.Rows.Count; i++)
{
menuclass.Id = Convert.ToInt32(dt2x.Rows[i]["Id"]);
menuliste.Add(menuclass);
menuclass = new AP_City();
}
}
return menuliste;
}
这是我的课
namespace Deneme
{
public class AP_City
{
public int Id { get; set; }
}
}
【问题讨论】:
标签: c# asp.net list web-services get