I am new to asp.net and stuck in a very silly issue. But I canβt understand. I have a form that is filled with data from the database on page_load, and the user updates the text for entering the form and clicks the Refresh button. It is updated, but updated 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); }
procedure is stored here
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
source share