how to put and use two flags(insert and update flags) on a single button to perform two operations in asp.net with C#

var record = du.SelectQuery("select * from where Crop_Master Crop_Name="@Crop_Name");
if(record.Count > 0) {
    du.ExecQry("Update Crop_Master set Crop_Name= ""+TextBox1.Text+"' where Crop_Name="@Crop_Name" ");
} else {
    du.ExecQry("insert into Crop_Master(Crop_Name,Created_On,Created_By,Created_By_Ip)values('" + TextBox1.Text + "',GETDATE(),'" + ViewState["user"] + "','" + ViewState["ip"] + "')");
}
Label2.Text = "Submitted";
Label2.ForeColor = System.Drawing.Color.Green;

I Just help you out with task, but don’t like about your coding and db design style…

be more professional

Leave a Comment