: "DBHelper"的类型初始值设定项引发异常.
using(SqlConnectionconn=newSqlConnection(DBHelper.connString)){stringsql=string.Forma...
using (SqlConnection conn = new SqlConnection(DBHelper.connString))
{
string sql = string.Format("update [HY] set 密码='{0}' where 用户名='{1}'", textBox2.Text.Trim(), UserHelper.userName);
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
int n = Convert.ToInt32(cmd.ExecuteNonQuery());
if (n != 1)
{
MessageBox.Show("密码修改失败!");
}
else
{
MessageBox.Show("密码修改成功!");
UserHelper.password = textBox2.Text.Trim();
}
}
class DBHelper
{
public static string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}
求解决 急 展开
{
string sql = string.Format("update [HY] set 密码='{0}' where 用户名='{1}'", textBox2.Text.Trim(), UserHelper.userName);
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
int n = Convert.ToInt32(cmd.ExecuteNonQuery());
if (n != 1)
{
MessageBox.Show("密码修改失败!");
}
else
{
MessageBox.Show("密码修改成功!");
UserHelper.password = textBox2.Text.Trim();
}
}
class DBHelper
{
public static string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}
求解决 急 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询