我正在尝试使用从网站上的多个txtbox传递给[WebMethod]的信息来更新Access数据库。
[WebMethod]
public string changePersonalInfo(string email, string name, string id, string address, string contactDetails, string password, string question, string answer, string loggedInEmail)
我将所有信息传递给它天气它有没有价值。
if (email != "") //Wont execute if there is no value
{
cmd.CommandText = @"UPDATE BuyerInfo SET [emailAddress] = '" + email + "' WHERE (emailAddress = '" + loggedInEmail + "')";
}
if (name != "")
{
cmd.CommandText = @"UPDATE BuyerInfo SET [name] = '" + name + "' WHERE (emailAddress = '" + loggedInEmail + "')";
}
if (id != "")
{
cmd.CommandText = @"UPDATE BuyerInfo SET [id] = '" + id + "' WHERE (emailAddress = '" + loggedInEmail + "')";
}
//etc. It goes on for a few more.
cmd.ExecuteNonQuery();
conn.Close();
问题是当我运行网站时它只更新网站上最后一个txtbox的数据(换句话说,最后一个有值的变量)。我该如何解决这个问题,或者是否有更好的方法来解决这个问题。 P.S请记住,我是Web Services的新手。 感谢名单