Hazel Ortiz

Generation

generate functionThu, 13 Jul 2023

validar si en la fecha ingresada en el txt hay datos en la base de datos c# asp

private void btnValidar_Click(object sender, EventArgs e) { int n = 0; SqlConnection sqlCon = new SqlConnection(@"Data Source=.;Initial Catalog=PRUEBA;Integrated Security=True"); sqlCon.Open(); SqlCommand comando = new SqlCommand("SELECT COUNT(*) FROM dbo.Ventas WHERE fechaVentas = '" + txtFecha.Text + "'", sqlCon); n = comando.ExecuteNonQuery(); if (n>0) { MessageBox.Show("si existe"); } else { MessageBox.Show("no existe"); } }

Questions about programming?Chat with your personal AI assistant