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()里面的内容了
更新不了 密码 请指教!!! 谢谢了 小弟没有多少分了!
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()里面的内容了
更新不了 密码 请指教!!! 谢谢了 小弟没有多少分了!
{
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"];
即可
string strConnection="Server=.;uid=sa;password=;DataBase=BookLibrary";
好像没有错吧!
您说的这种不太懂!
就能调出那里错
看ex是什么错误