日期:2014-05-20  浏览次数:20385 次

白兄近来帮忙解决一下问题好吗?高手也近来拿分呀!
ASP.NET增删改(改的问题)我是有用一个DataGrid绑定的超级连接列,然后进入详细显示数据页面!在TEXTBOX中显示数据!现在遇到修改更新不了数据库的问题!点修改按钮的时候显示修改成功但是在SQL中一查询数据还是老的数据!并没有修改过!我的程序一共有两个类,一个操作类,一个实体类,cnat_id是数据库主键

操作类代码:

public   static   bool   updateOperate(person   p)
{
try
{
SqlConnection   con=personOperate.createCon();
con.Open();
SqlCommand   cmd=new   SqlCommand( "update   cnatword   set   jgsj= ' "+p.cnat_1+ " ',jgr= ' "+p.cnat_2+ " ',sfzp= ' "+p.cnat_x1+ " ',wydw= ' "+p.cnat_3+ " ',gglb= ' "+p.cnat_4+ " ',sgzq= ' "+p.cnat_5+ " ',gzyq= ' "+p.cnat_6+ " ',yhyq= ' "+p.cnat_7+ " ',ywyq= ' "+p.cnat_8+ " ',zzlb= ' "+p.lb+ " ',ywpj= ' "+p.pj+ " ',ywqrsj= ' "+p.cnat_9+ " ',sc= ' "+p.cnat_10+ " ',sccc= ' "+p.cnat_11+ " ',jd= ' "+p.cnat_12+ " ',jdcc= ' "+p.cnat_13+ " ',zzr= ' "+p.cnat_21+ " ',wcsx= ' "+p.cnat_22+ " ',wcsj= ' "+p.cnat_14+ " ',fh= ' "+p.cnat_15+ " ',web= ' "+p.cnat_x5+ " ',kb= ' "+p.cnat_x6+ " ',javascript= ' "+p.cnat_x7+ " ',bc= ' "+p.cnat_x8+ " ',flashbc= ' "+p.cnat_x9+ " ',dlwc= ' "+p.cnat_x10+ " ',sjkbc= ' "+p.cnat_x11+ " ',divcss= ' "+p.cnat_x12+ " ',qzhr= ' "+p.cnat_16+ " ',yhqz= ' "+p.cnat_17+ " ',zkb= ' "+p.cnat_18+ " ',syrj= ' "+p.cnat_19+ " ',zjjy= ' "+p.cnat_20+ " '   where   cnat_id= ' "+p.cnat_id+ " ' ",con);                
cmd.ExecuteNonQuery();
return   true;
}
catch(Exception   e)
{
return   false;
}

实体类代码:

public   class   person
{
public   string   cnat_1;
public   string   cnat_2;
public   string   cnat_3;
public   string   cnat_4;
public   string   cnat_5;
public   string   cnat_6;
public   string   cnat_7;
public   string   cnat_8;
public   string   cnat_9;
public   string   cnat_10;
public   string   cnat_11;
public   string   cnat_12;
public   string   cnat_13;
public   string   cnat_14;
public   string   cnat_15;
public   string   cnat_16;
public   string   cnat_17;
public   string   cnat_18;
public   string   cnat_19;
public   string   cnat_20;
public   string   cnat_x1;
public   string   pj;
public   string   cnat_x5;
public   string   cnat_x6;
public   string   cnat_x7;
public   string   cnat_x8;
public   string   cnat_x9;
public   string   cnat_x10;
public   string   cnat_x11;
public   string   cnat_x12;
public   string   cnat_21;
public   string   cnat_22;
public   string   lb;
public   string   cnat_id;
public   person()
{

------解决方案--------------------
代码号多哇。。。
if(dt.Rows[0][ "sfzp "].ToString().Equals( "是 "))