Reputation: 175
i have some problem here with Edit Data Using ASP.NET Razor in WebMatrix i write this code for edit a data using the Update command but unfortunately it doesnt work :s :s
Razor code :
@{
{
var userId = Request["UserId"];
var db = Database.Open("intranet");
var query = "UPDATE Personne SET Demande = @0 WHERE UserId LIKE '%@1%'";
db.Execute(query,"refuser", userId);
}
}
the html code :
<form action="responsable.cshtml" method="post">
<input type="hidden" name="UserId" value="saadwafqui" />
<input type="submit" value="Oui" />
Upvotes: 0
Views: 287
Reputation: 19
You can use the following code:
@{
if (IsPost){
var userId = Request["UserId"];
var db = Database.Open("intranet");
var query = "UPDATE Personne SET Demande = @0 WHERE UserId LIKE '%" + userId + "%'";
db.Execute(query,"refuser" );
}
}
the html code :
<form action="responsable.cshtml" method="post">
<input type="hidden" name="UserId" value="saadwafqui" />
<input type="submit" value="Oui" />
Upvotes: 0
Reputation: 1038810
Try like this:
var query = "UPDATE Personne SET Demande = @0 WHERE UserId LIKE '%'+@1+'%'";
Upvotes: 1