Hello everyone
I am trying to select the maximum value, and automatically generate the Product Code.
This is the Code, but it doesn't come out.
try
{
using(var Conexion = new SqlConnection(VariablesGlobales.CadenaConexion))
{
Conexion.Open();
string consultaSQL = "select Max(CodigoProducto) As maximo FROM TblaProducto2";
var comando = new SqlCommand(consultaSQL, Conexion);
SqlDataReader LD = comando.ExecuteReader();
if(LD.Read() == true)
if(maximo = 0)
{
txtCodigo1.Text = "1";
}
else
{
maximo = maximo + 1;
txtCodigo1.Text = maximo;
}
{}
}
}
catch(Exception ex) //
{
MessageBox.Show("Error al intentar seleccionar el valor maximo");
MessageBox.Show(ex.Message); // Muestra el Mensaje de Error.
}

I count on your help