I have a form in ASP.NET where I want to increase the Id in a textbox and show it in the text box, every time the user clicks on a button, it has to be updated.
Do this code but it does not work for me, it does not show the Folio in the text box
private void Id()
{
SqlConnection conn = new SqlConnection();
conn = new SqlConnection(this.conexion);
conn.Open();
SqlCommand cmd = new SqlCommand();
try
{
cmd.CommandText = "select max(Folio) from Datos;";
int valor = int.Parse(cmd.ExecuteScalar().ToString()) + 1;
txtfolio.Text = Convert.ToString(valor);
}
catch(System.Exception ex)
{
}
}
The method I added it in the High button:
protected void Alta_Click(object sender, EventArgs e)
{
Id();
}