日期:2014-05-18  浏览次数:20415 次

updata 无法更新数据库 请求帮忙!
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()里面的内容了
更新不了   密码     请指教!!!   谢谢了   小弟没有多少分了!

------解决方案--------------------
catch(Exception ex)
{
this.LabError.Text= "密码修改失败!!! "+ex.Message;
this.LabError.ForeColor=Color.Red;
}
------解决方案--------------------
第一行字符串错了吧!
你这么写,把以下这行代码加入到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 "];
即可

------解决方案--------------------
你写成Session[ "uCard "].ToString()试试!
------解决方案--------------------
现在本身就判断不清楚问题所在,干吗还加try啊,先去掉try吧
------解决方案--------------------
先把try catch去掉
就能调出那里错
------解决方案--------------------
单步调试一下,走到(this.LabError.Text= "密码修改失败!!! "+ex.Message;)
看ex是什么错误
------解决方案--------------------
把SQL语句写出来

用在 SQL Server运行一下