2016-01-21 74 views
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 

我的數據庫有什麼問題嗎?

+0

代碼看起來fine.can您包括您所輸入的樣本數據,並且已經在那裏的管理用戶數據s表中的任何AdminUserID的問題? – Martin

+0

作爲一個完整的考慮,考慮對'SqlConnection'和'SqlCommand'使用'using'語句。它們都實現了'IDisposable'接口並且可以利用它。只是一個念頭 - 最後,這是你的呼喚。 –

回答

0

能否向我們提供關於表結構的更多信息?我可以想到列的大小寫,你在哪個操作系統上使用數據庫?

根據我的經驗,在Linux中,我們應該注意大小寫影響的代碼,而在Windows它不會(通常我的代碼全部用大寫)

編輯:

不該」 t將其成爲=

cmd = new SqlCommand("Update AdminUsers Set [email protected], [email protected], 
        [email protected], [email protected], [email protected], [email protected] 
       Where [email protected]", conn); 

我沒有看到任何AdminUserID列有

相關問題