用户修改资料不能提交到数据库中,大家看看代码,怎么改?各位帮忙,谢了.
protected void btnCommit_Click(object sender, EventArgs e)
{
string sql = "Update [User] Set UserTrueName=@userTrueName,Sex=@sex,Age=@age,Marry=@marry,IDcard=@idCard,Mobile=@mobile,QQ=@qq,[E-Mail]=@email Where UserName= ' " + Request.Cookies[ "cookieUserName "].Value.Trim() + " ' ";
string connStr = ConfigurationManager.ConnectionStrings[ "dbcon "].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add( "@userTrueName ", SqlDbType.Char, 20);
cmd.Parameters.Add( "@sex ", SqlDbType.Char, 4);
cmd.Parameters.Add( "@age ", SqlDbType.Int, 4);
cmd.Parameters.Add( "@marry ", SqlDbType.Char, 8);
cmd.Parameters.Add( "@idCard ", SqlDbType.Char, 18);
cmd.Parameters.Add( "@mobile ", SqlDbType.Char, 16);
cmd.Parameters.Add( "@qq ", SqlDbType.Real, 12);
cmd.Parameters.Add( "@email ", SqlDbType.Char, 40);
if (tbtruename.Text != null && tbtruename.Text != string.Empty)
{
cmd.Parameters[ "@userTrueName "].Value = tbtruename.Text;
}
else
{
cmd.Parameters[ "@userTrueName "].Value = " ";
}
cmd.Parameters[ "@sex "].Value = rblistsex.Text;
if (tbage.Text != null && tbage.Text != string.Empty)
{
cmd.Parameters[ "@age "].Value = Int32.Parse(tbage.Text);
&nbs