I am new to asp.net and stuck at a very stupid problem. But I cannot figure it out. I have a form which is filled by data from DB on page_load, and user update the form's input's text and click the "update" button. It updates but it updates with old data.
WHY DOES IT UPDATE IT WITH OLD DATA?
here is the aspx form
<form id="form1" runat="server">
<table>
<tr>
<td>ID</td>
<td><asp:Label ID="lbl_id" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td>FirstName</td>
<td><asp:TextBox ID="txt_firstname" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>LastName</td>
<td><asp:TextBox ID="txt_lastname" runat="server"></asp:TextBox></td>
</tr>
</table>
here is the code behind
protected void Guncelle_Click(object sender, EventArgs e)
{
DbCommand dbCommand;
dbCommand = db.GetStoredProcCommand("MedBul_Update_Registration_Request");
db.AddInParameter(dbCommand, "id", DbType.Int16, request_id);
db.AddInParameter(dbCommand, "FirstName", DbType.String, txt_firstname.Text.ToString().Trim());
db.AddInParameter(dbCommand, "LastName", DbType.String, txt_lastname.Text.ToString().Trim());
db.ExecuteNonQuery(dbCommand);
}
here is the stored procedure
Create PROCEDURE [dbo].[MedBul_Update_Registration_Request]
(@id int,@FirstName varchar(50),@LastName varchar(50))
AS
BEGIN
update NewProfessionalRequest set FirstName= @FirstName, LastName =@LastName
where id = @id
END
GO