一个数据更新的问题,摸不着头脑。

Hilltown 2003-09-24 04:42:17
代码如下:
string str= "update yhxx set dw='"+this.dw1.Text+" ',xm='"+this.xm1.Text +"', dh='" + this.dh1.Text + "',cz='" + this.cz1.Text + "',email='" + this.email1.Text + "',sjch='" + this.sjch1.Text+ "', bz='"+this.bz1.Text +"',rq='" + this.rq1.Text + "' where xh='"+this.Request["pro"].ToString()+"'";
conn.ConnectionString=this.Application["connstr"].ToString();
adap=new System.Data.SqlClient.SqlDataAdapter(str,conn);
ds=new System.Data.DataSet();
adap.Fill(ds, "table1");
ds.Clear();
this.Response.Write("<script>alert('数据修改完毕!');history.back();</script>");
执行时:提示“数据保存完毕”
上库里查看修改的这条记录时,跟原来一样没更新?同样格式写的删除语句就好使,不知道怎么回事?请教。
...全文
14 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
HappySummer 2003-10-14
  • 打赏
  • 举报
回复
cmd.Connection=myConnection
ahfann 2003-10-14
  • 打赏
  • 举报
回复
我也出现这种问题 ,不知为什么,我是这样写的
string str1="update person set cpersonpass ='"+TextBox2.Text+"' ,tel='"+TextBox4.Text+"' where cpersoneno='"+DropDownList1.SelectedItem.Text+"'";
sqlCommand1.CommandText = str;
sqlConnection1.Open();
sqlCommand1.ExecuteNonQuery();
sqlConnection1.Close();
我的sql语句一定没错,但不知为什么,出现和楼主一样的问题
lucidaxy 2003-10-09
  • 打赏
  • 举报
回复
用查询分析器分析构造后sql语句,估计是更新条件有问题,导致影响行数为0行
Hilltown 2003-10-09
  • 打赏
  • 举报
回复
这个问题还是没有解决,xh='"+this.Request["pro"].ToString()+"'"传递来的参数“pro"在新的页面中能打印出来,但不知为何就是不更新数据。
Hilltown 2003-09-24
  • 打赏
  • 举报
回复
可能是条件不对吧,但还是不行!string str= "update yhxx set dw='"+this.dw1.Text+" ',xm='"+this.xm1.Text +"', dh='" + this.dh1.Text + "',cz='" + this.cz1.Text + "',email='" + this.email1.Text + "',sjch='" + this.sjch1.Text+ "', bz='"+this.bz1.Text +"',rq='" + this.rq1.Text + "' where xh='"+this.Request["pro"].ToString()+"'";
可能是它的问题。
vbcb 2003-09-24
  • 打赏
  • 举报
回复
string str= "update yhxx set dw='"+this.dw1.Text+" ',xm='"+this.xm1.Text +"', dh='" + this.dh1.Text + "',cz='" + this.cz1.Text + "',email='" + this.email1.Text + "',sjch='" + this.sjch1.Text+ "', bz='"+this.bz1.Text +"',rq='" + this.rq1.Text + "' where xh='"+this.Request["pro"].ToString()+"'";
conn.ConnectionString=this.Application["connstr"].ToString();
SqlCommand myCommand = new SqlCommand(str, conn);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
str="SELECT * FROM yhxx";
adap=new System.Data.SqlClient.SqlDataAdapter(str,conn);
ds=new System.Data.DataSet();
adap.Fill(ds, "yhxx");
ds.Clear();
this.Response.Write("<script>alert('数据修改完毕!');history.back();</script>");
这样子就对了,你试试看
guoyan19811021 2003-09-24
  • 打赏
  • 举报
回复
string str= "update yhxx set dw='"+this.dw1.Text+" ',xm='"+this.xm1.Text +"', dh='" + this.dh1.Text + "',cz='" + this.cz1.Text + "',email='" + this.email1.Text + "',sjch='" + this.sjch1.Text+ "', bz='"+this.bz1.Text +"',rq='" + this.rq1.Text + "' where xh='"+this.Request["pro"].ToString()+"'";
conn.ConnectionString=this.Application["connstr"].ToString();
cmd=new System.Data.SqlClient.Sqlcommand(str,conn);
adap=new System.Data.SqlClient.SqlDataAdapter();
adap.selectcommand=cmd
ds=new System.Data.DataSet();
adap.Fill(ds, "table1");
ds.Clear();
this.Response.Write("<script>alert('数据修改完毕!');history.back();</script>");
如果还不行,看看sql语句
潜水员2099 2003-09-24
  • 打赏
  • 举报
回复
QuickStart 安装了吗?
参考:
http://localhost/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid6.src
xrll 2003-09-24
  • 打赏
  • 举报
回复
if(!IsPostBack){
///在此绑定
Binding()
}
2002pine 2003-09-24
  • 打赏
  • 举报
回复
你可以把你的str,在调试时,拷贝下来,在sql server查询分析器中运行,看有没有结果,
我估计是你的条件不对。所以没有记录被更新
acewang 2003-09-24
  • 打赏
  • 举报
回复
public void CreateMySqlCommand(string myExecuteQuery, SqlConnection myConnection)
{
SqlCommand myCommand = new SqlCommand(myExecuteQuery, myConnection);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧