【问题标题】:Delete and update with stored procedure in ormlite (SQL Server) & C#使用 ormlite (SQL Server) 和 C# 中的存储过程删除和更新
【发布时间】:2017-04-14 02:40:43
【问题描述】:

尝试使用 ormlite 中的存储过程进行更新。我目前有这个,但它似乎没有工作。没有错误显示,什么都不做。

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 });
}

还有什么方法可以删除?

【问题讨论】:

    标签: c# asp.net sql-server ormlite-servicestack


    【解决方案1】:

    如果存储过程没有返回任何内容,请改用db.ExecuteSql(),例如:

    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 });
    

    Delete 也是如此:

    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 });
    

    【讨论】:

    • 我确实尝试过,但现在出现错误。在 ExecuteSql 上
    猜你喜欢
    • 1970-01-01
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    • 2021-09-25
    • 2014-06-23
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多