2
我在更新MyAccount,但只有一列[密碼]正在更新。以下是我的代碼。請幫忙謝謝。爲什麼我的表數據庫中只有一列正在更新?
private string connstr =
System.Web.Configuration.WebConfigurationManager.ConnectionStrings
["ConnectionString"].ConnectionString;
private SqlConnection conn;
private SqlCommand cmd;
conn = new SqlConnection(connstr);
cmd = new SqlCommand("Update AdminUsers Set [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected]
Where [email protected]", conn);
cmd.Parameters.AddWithValue("@AdminUserID", lblAdminMyAcctID.Text);
cmd.Parameters.AddWithValue("@Name", txtAdminMyAcctName.Text);
cmd.Parameters.AddWithValue("@UserName", txtAdminMyAcctUserName.Text);
cmd.Parameters.AddWithValue("@Address", txtAdminMyAcctAddress.Text);
cmd.Parameters.AddWithValue("@Phone", txtAdminMyAcctPhone.Text);
cmd.Parameters.AddWithValue("@Email", txtAdminMyAcctEmail.Text);
cmd.Parameters.AddWithValue("@Password", txtAdminMyAcctNewPassword.Text);
conn.Open();
if (cmd.ExecuteNonQuery() == 1)
{
}
conn.Close();
Here are my Data at my Database
ID Name UserName Address Phone Email UserType Branch Status Password
4 Default Admin Auckland 64 123 45678910 [email protected] Admin Main True admin
6 Groomer Groomer2 Main 0221210801 [email protected] Groomer Glen Ines True groomer3
7 Groomer Groomer1 Main 0221210800 [email protected] Groomer Duniden True groomer1
我的數據庫有什麼問題嗎?
代碼看起來fine.can您包括您所輸入的樣本數據,並且已經在那裏的管理用戶數據s表中的任何AdminUserID的問題? – Martin
作爲一個完整的考慮,考慮對'SqlConnection'和'SqlCommand'使用'using'語句。它們都實現了'IDisposable'接口並且可以利用它。只是一個念頭 - 最後,這是你的呼喚。 –