以下是代码,我想在jquery ajax中使用返回数据 任何人都可以告诉我,我是这个新手
[WebMethod(EnableSession=true)]
public static string GetName(string Name)
{
if (HttpContext.Current.Session["MyCart"] != null)
{
string Id = Convert.ToString(HttpContext.Current.Session["MyCart"]);
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Products"].ConnectionString);
SqlCommand cmd = new SqlCommand("Select Name from Product where Id in (" + Id + ")", cn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Name = dr["Name"].ToString();
}
dr.Close();
cn.Close();
}
return Name;
}