我不明白为什么这不起作用?!Sql更新问题
protected void Submit_Click(object sender, EventArgs e)
{
Update();
}
public void Update()
{
try
{
using (SqlConnection conn =
new SqlConnection(conStr))
{
conn.Open();
using (SqlCommand cmd =
new SqlCommand("UPDATE DriverInfo SET [email protected], [email protected], [email protected], [email protected], [email protected] WHERE [email protected]", conn))
{
cmd.Parameters.AddWithValue("@Id", currentUserId);
cmd.Parameters.AddWithValue("@NewFirstName", tbfirstname.Text);
cmd.Parameters.AddWithValue("@NewLastName", tblastname.Text);
cmd.Parameters.AddWithValue("@NewAge", tbage.Text);
cmd.Parameters.AddWithValue("@NewCountry", tbcountry.Text);
cmd.Parameters.AddWithValue("@NewTown", tbtown.Text);
int rows = cmd.ExecuteNonQuery();
//rows number of record got updated
}
}
}
catch (SqlException ex)
{
//Log exception
//Display Error message
}
}
这应该是一个页面,登录的用户可以更改他的设置,他们应该在数据库中更新。
和你的错误是什么? – 2011-12-30 13:16:31
除了数据库没有更新之外,没有错误。我知道连接工作,因为我已经使用了许多其他功能相同的连接字符串。 – parek 2011-12-30 13:18:42
告诉我们错误 – 2011-12-30 13:19:21