Delete and update with stored procedure in ormlite (SQL Server) & C#

安稳与你 提交于 2019-12-11 02:46:37

问题


Trying to update using stored procedures in ormlite. I currently have this but it doesn't seem to be working. No error displayed, just does nothing.

public void UpdateUsers(DATOS.Users users)
{
    _db.SqlScalar<DATOS.Users>("exec updateUsers set @Username, @password, @id_room, @id_rol", new { Username = users.Username, Password = users.password, Id_room = users.id_room, id_rol = users.id_rol });
}

Also what will do the trick for the delete?


回答1:


If the stored procedure doesn't return anything use db.ExecuteSql() instead, e.g:

db.ExecuteSql("exec updateUsers @Username, @password, @id_room, @id_rol", 
    new { Username = users.Username, 
          Password = users.password, 
          Id_room = users.id_room, 
          id_rol = users.id_rol });

Likewise with Delete's:

db.ExecuteSql("exec deleteUsers @Username, @password, @id_room, @id_rol", 
    new { Username = users.Username, 
          Password = users.password, 
          Id_room = users.id_room, 
          id_rol = users.id_rol });


来源:https://stackoverflow.com/questions/43404468/delete-and-update-with-stored-procedure-in-ormlite-sql-server-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!