后台代码:
public partial class GetDataFromD : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label2.Text = DateTime.Now.ToString();//检测是否实现了局部刷新 } [WebMethod] public static string GetBankNameByAccount(int Account) { string BankName = ""; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString)) { conn.Open(); string sql = "select Name from customers where id=@Account"; SqlCommand cmd = new SqlCommand(sql,conn); SqlParameter p = new SqlParameter("@Account",Account); cmd.Parameters.Add(p); using (SqlDataReader r = cmd.ExecuteReader()) { if(r.Read()) { BankName= r[0].ToString(); } } } return BankName; } [WebMethod] public static string GetName() { return "Hello"; } }