首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

updata 无法更新数据库 请求帮忙!该如何解决

2012-01-31 
updata 无法更新数据库 请求帮忙!stringstrConnection Server.uidsapasswordDataBaseBookLibrary

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运行一下

热点排行