存储过程+Jquery+WebService实现三级联动
存储过程的写法:
ALTER proc [dbo].@city_pid int">pro_GetCity
as
begin
—SELECT FROM tbl_city WHERE city_pid IN (
select from tbl_city where city_pid=@city_pid
end
—exec [dbo].[pro_GetCity] 0
服务层的代码:
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
[System.Web.Script.Services.ScriptService]
[WebMethod]
public string CityList(string citycode)
{
return JsonHelper.GetJson<List<tbl_city>>(new SelectComboxBLL().CityList(citycode));
}
数据访问层的代码:
public List CityList(string citycode)
{
SqlParameter[] pars = { new SqlParameter(“@city_pid”, citycode) };
return new SQLBase().TableToEntity(DBhelp.SqlHelper.GetTable(“pro_GetCity”, System.Data.CommandType.StoredProcedure, pars));
}
业务层:
public List CityList(string citycode)
{
return new SelectCombox().CityList(citycode);
}
最核心的jquery调用WebService: