ASP.NET 数据更新的问题

sunxb008 2006-08-20 10:07:47
功能: 从DATAGRID 传数据到新的页面,进行编辑后更新到数据库,
请问一下,为什么向SQL中更新数据时能正能运行,又能得到返到影响的行数,可是打开数据库后,却不见数据有变动,这是为什么?谢谢
...全文
124 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xu8512 2006-08-20
  • 打赏
  • 举报
回复
应该是缓存再dataset里面了,没有更新dataset
sunxb008 2006-08-20
  • 打赏
  • 举报
回复
部分代码:
string code = Tbox_code.Text.Trim() ;
string name = Tbox_name.Text.Trim();
string birday = TBox_birthday.Text.Trim();
string sex = RbList_sex.SelectedItem.Value.Trim();
string num = Tbox_num.Text.Trim();
string tel = Tbox_tel.Text.Trim();
string phone = Tbox_phone.Text.Trim();
string email = Tbox_email.Text.Trim();
string classes = DdList_class.SelectedValue.Trim();

string strSQL = "update humaninfo set code = @code , name=@name , birdate=@birday ,";
strSQL+= "sex=@sex , number=@number , telephone=@telphone ,phone=@phone ";
strSQL+= "email=@email ,class=@class ,photo=@photo , photopath=@photopath where code = @code";
SqlCommand updateCommand =new SqlCommand(strSQL,myConn);

//设置参数的值
updateCommand.Parameters.Add(new SqlParameter("@code",SqlDbType.VarChar));
updateCommand.Parameters["@code"].Value = code;

updateCommand.Parameters.Add(new SqlParameter("@name",SqlDbType.VarChar));
updateCommand.Parameters["@name"].Value = name;

updateCommand.Parameters.Add(new SqlParameter("@birday",SqlDbType.DateTime));
updateCommand.Parameters["@birday"].Value = birday;

updateCommand.Parameters.Add(new SqlParameter("@sex",SqlDbType.VarChar));
updateCommand.Parameters["@sex"].Value = sex;

updateCommand.Parameters.Add(new SqlParameter("@number",SqlDbType.VarChar));
updateCommand.Parameters["@number"].Value = num;

updateCommand.Parameters.Add(new SqlParameter("@telphone",SqlDbType.VarChar));
updateCommand.Parameters["@telphone"].Value = tel;

updateCommand.Parameters.Add(new SqlParameter("@phone",SqlDbType.VarChar));
updateCommand.Parameters["@phone"].Value = phone;

updateCommand.Parameters.Add(new SqlParameter("@email",SqlDbType.VarChar));
updateCommand.Parameters["@email"].Value = email;

updateCommand.Parameters.Add(new SqlParameter("@class",SqlDbType.VarChar));
updateCommand.Parameters["@class"].Value = classes;

updateCommand.Parameters.Add(new SqlParameter("@photo",SqlDbType.Image));
updateCommand.Parameters["@photo"].Value = imgBinaryData;

updateCommand.Parameters.Add(new SqlParameter("@photopath",SqlDbType.VarChar));
updateCommand.Parameters["@photopath"].Value = photopath;

myConn.Open();
updateCommand.ExecuteNonQuery();


好像有人说:是TextBox从库中取数据的时候将数据都存在了缓存中,当更新的时候所以更新成功,也全是从缓存中用原来的数据更新了原来的数据,具体情况请各位高人指点一点
www_123du_com 2006-08-20
  • 打赏
  • 举报
回复
"为什么向SQL中更新数据时能正能运行,又能得到返到影响的行数"----有可能是用了事务没有提交(但从这里看,似乎不像这种情况)

62,046

社区成员

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

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

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

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