【发布时间】:2016-07-30 07:13:26
【问题描述】:
我尝试通过 json 或 jquery ajax 从 webservice 获取双 DataTable
WebService 方法:
[WebMethod]
public DataSet FareAccpted_(string custId)
{
DataSet ds = new DataSet();
List<fareAccptedList> details = new List<fareAccptedList>();
using (SqlConnection con = new SqlConnection("..."))
{
using (SqlCommand cmd = new SqlCommand("proc_FareAcceptedC", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@customerId", SqlDbType.Int).Value = custId;
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
}
return ds;
}
Js页面:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../lpService.asmx/FareAccpted_",
data: JSON.stringify({ custId: custId_ }),
dataType: "json",
success: function (data) {
alert('Length : '+data.d.length)
},
error: function (result) {
alert("FareAcceptedC" + "Error");
}
});
DataTables 存储在 DataSet 中。
【问题讨论】:
-
你试过了......发生了什么?请添加更多详细信息。有什么问题?服务是做什么的?你想完成什么?
-
嗨,Sami,感谢您的宝贵回复,我再次正确编辑了我的问题,您可以看到并帮助我,Thanx 提前:)