2015-05-03 33 views
0

我无法弄清我的更新功能。我能够从我的数据库中检索和删除,但我不知道如何更新。这对我来说都是新的,所以我很难过。CRUD更新不正常

js文件

//update user 
$("#btnUpdateUser").click(function() { 

     $.ajax({ 
      type: 'PUT', 
      url: uri, 
      data: JSON.stringify(vendor), 
      processdata: true, 



    public int updateUser(vendors vendors, int id) 
    { 


      SqlCommand cmd = new SqlCommand("UPDATE vendors set [user][email protected], [email protected], [email protected], [email protected], [email protected] where [email protected]", con); 
      cmd.Parameters.AddWithValue("@id", id); 
      cmd.Parameters.AddWithValue("@user", vendors.user); 
      cmd.Parameters.AddWithValue("@email", vendors.email); 

我得到一个“未发现记录”之前,但我不再得到那个。 任何指导/提示将不胜感激。

+2

你确定你想更新id字段? –

+0

你使用的是实体框架还是类似的东西? –

+0

另外,请告诉我们您正在使用的数据库后端。 –

回答

1

要做的最好的事情是进入调试器模式,并在visual studio中的文件vender.cs的updateUser方法的开头添加一个断点。

检查所有的变量都通过了vendersid悬停鼠标预期(我怀疑你缺少,包括你的URL调用的ID?)

还有一点要检查 - 我注意到你正在尝试更新ID,这不是很好的做法。 - 删除

+0

感谢您的帮助。我已经删除了我的ID的更新。我会调试并看看我得到了什么。 – user3353920

0

我猜URI缺少ID或有错误的ID(期间记录的抓取)