string strConnection="Server=.;uid=sa;password=;DataBase=BookLibrary";
string upDataStr="updata UserInfo set uPassword='"+this.newPawText.Text+"' where (uCard='"+Session["uCard"]+"') ";
SqlConnection myConn=new SqlConnection(strConnection);
myConn.Open();
SqlCommand myCom=new SqlCommand(upDataStr,myConn);
try
{
myCom.CommandText=upDataStr;
myCom.ExecuteNonQuery();
myConn.Close();


}
catch
{
this.LabError.Text="密码修改失败!!!";
this.LabError.ForeColor=Color.Red;
}执行到myCom.ExecuteNonQuery();以后就执行Catch()里面的内容了
更新不了 密码  请指教!!! 谢谢了 小弟没有多少分了!

解决方案 »

  1.   

    catch(Exception ex)
    {
    this.LabError.Text="密码修改失败!!!"+ex.Message;
    this.LabError.ForeColor=Color.Red;
    }
      

  2.   

    第一行字符串错了吧!
    你这么写,把以下这行代码加入到web.config
    <configuration>
    </configSections>
    <appSettings>
    <add key="conn" value="Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=Blog;Data Source=127.0.0.1;"/>(根据自己情况修改)
    </appSettings>
    <configuration>
    页面中要用到数据库连接时
    string strConnection = ConfigurationSettings.AppSettings["conn"];
    即可
      

  3.   

    数据库链接字符串吗?
    string strConnection="Server=.;uid=sa;password=;DataBase=BookLibrary";
    好像没有错吧!
    您说的这种不太懂!
      

  4.   

    你写成Session["uCard"].ToString()试试!
      

  5.   

    现在本身就判断不清楚问题所在,干吗还加try啊,先去掉try吧
      

  6.   

    输出upDataStr,到查询分析器执行一下,什么都明白了
      

  7.   

    先把try catch去掉
    就能调出那里错
      

  8.   

    单步调试一下,走到(this.LabError.Text="密码修改失败!!!"+ex.Message;)
    看ex是什么错误
      

  9.   

    把SQL语句写出来用在 SQL Server运行一下