0
得到錯誤未設置爲在SQL命令對象的實例,同時初始化命令文本.unable在SQL命令對象添加SQL更新查詢對象引用在asp.net
TextBox id = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtid");
TextBox Loginid = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtgvusername");
TextBox EmployeeId = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtEmployeeId");
TextBox Fullname = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtFullname");
TextBox Password = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtPassword");
TextBox ContactNo = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtContactNo");
TextBox MailId = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtMailid");
TextBox Location = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtLocation");
TextBox Roles = (TextBox)gvUserDetails.Rows[e.RowIndex].FindControl("txtRoles");
CheckBox chkLeads = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("chkLeads");
CheckBox ChkSales = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("ChkSales");
CheckBox ChkReports = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("ChkReports");
CheckBox ChkPayments = (CheckBox)gvUserDetails.Rows[e.RowIndex].FindControl("ChkPayments");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Update tbl_AdminLogin set FullName='" + txtfullName.Text + "',Password='" + txtPassword.Text + "',ContactNo='" + txtContact.Text + "',Mailid='" + txtMailid.Text + "',Location='" + txtLocation.Text + "',Roles='" + Roles.Text + "',Leads='" + chkLeads.Text + "',Sales='" + ChkSales.Checked + "',Reports='" + ChkSales.Text + "',Payments='" + ChkPayments.Text + "',EmployeeId='" + id.Text + "' where id='" + id.Text + "'";//getting error here
** [可能的SQL注入](https://msdn.microsoft.com/en-us/library/ms161953%28v=sql.105%29.aspx)** – lad2025
將密碼存儲爲純文本並不好要麼。 – lad2025
'id'爲空,您沒有在'id'中獲取任何文本框 – Hemal