问题
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