I have a search button and datagrid in c# and SQL
-
hi all
I have a search button and datagrid in c#, I require perform a query in the database and load the data in me datagrid
it is my code
conexion.ConnectionString = @"Data Source = SHINIL-PC040\SQLEXPRESS; Initial Catalog = produccion; Integrated Security = True";
if(TXTORDEN_PRODUCCION.Text == "" || TXTTURNO.Text == "" || TXTMAQUINAS.Text == "" || TXTHORAINICIO.Text == "" || TXTHORAFIN.Text == "")
{
MessageBox.Show("Te falta campo");
}
else
{if (checkBox1.Checked == true) { try { comando.Connection = conexion; conexion.Open(); string SqlAction = "select orden, turno, operador, horainicio, horafin, articulo, totalpiezasok, totalcajas, piezascondefecto, maquina from conteo2 where CONVERT(varchar(10), horafin, 108) >= @horainicio and CONVERT(varchar(10), horafin, 108)<= @horafin and orden = @orden and turno = @turno and maquina = @maquina "; // "SELECT MOLDE, PROYECTO, ITEMPARTE, COLOR, SNP FROM PARTE WHERE ITEMPARTE = @ITEMPARTE"; SqlCommand cmd = new SqlCommand(SqlAction, conexion); cmd.Parameters.AddWithValue("@orden", TXTORDEN\_PRODUCCION.Text); cmd.Parameters.AddWithValue("@turno", TXTTURNO.Text); cmd.Parameters.AddWithValue("@maquina", TXTMAQUINAS.Text); cmd.Parameters.AddWithValue("@horainicio", TXTHORAINICIO.Text); cmd.Parameters.AddWithValue("@horafin", TXTHORAFIN.Text); } conexion.Close(); } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } MessageBox.Show("selecciono ok produccion"); } if (checkBox2.Checked == true) { MessageBox.Show("selecciono paros"); } if (checkBox1.Checked == false & checkBox2.Checked == false) {
-
hi all
I have a search button and datagrid in c#, I require perform a query in the database and load the data in me datagrid
it is my code
conexion.ConnectionString = @"Data Source = SHINIL-PC040\SQLEXPRESS; Initial Catalog = produccion; Integrated Security = True";
if(TXTORDEN_PRODUCCION.Text == "" || TXTTURNO.Text == "" || TXTMAQUINAS.Text == "" || TXTHORAINICIO.Text == "" || TXTHORAFIN.Text == "")
{
MessageBox.Show("Te falta campo");
}
else
{if (checkBox1.Checked == true) { try { comando.Connection = conexion; conexion.Open(); string SqlAction = "select orden, turno, operador, horainicio, horafin, articulo, totalpiezasok, totalcajas, piezascondefecto, maquina from conteo2 where CONVERT(varchar(10), horafin, 108) >= @horainicio and CONVERT(varchar(10), horafin, 108)<= @horafin and orden = @orden and turno = @turno and maquina = @maquina "; // "SELECT MOLDE, PROYECTO, ITEMPARTE, COLOR, SNP FROM PARTE WHERE ITEMPARTE = @ITEMPARTE"; SqlCommand cmd = new SqlCommand(SqlAction, conexion); cmd.Parameters.AddWithValue("@orden", TXTORDEN\_PRODUCCION.Text); cmd.Parameters.AddWithValue("@turno", TXTTURNO.Text); cmd.Parameters.AddWithValue("@maquina", TXTMAQUINAS.Text); cmd.Parameters.AddWithValue("@horainicio", TXTHORAINICIO.Text); cmd.Parameters.AddWithValue("@horafin", TXTHORAFIN.Text); } conexion.Close(); } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } MessageBox.Show("selecciono ok produccion"); } if (checkBox2.Checked == true) { MessageBox.Show("selecciono paros"); } if (checkBox1.Checked == false & checkBox2.Checked == false) {
You never asked a question.
A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak -
hi all
I have a search button and datagrid in c#, I require perform a query in the database and load the data in me datagrid
it is my code
conexion.ConnectionString = @"Data Source = SHINIL-PC040\SQLEXPRESS; Initial Catalog = produccion; Integrated Security = True";
if(TXTORDEN_PRODUCCION.Text == "" || TXTTURNO.Text == "" || TXTMAQUINAS.Text == "" || TXTHORAINICIO.Text == "" || TXTHORAFIN.Text == "")
{
MessageBox.Show("Te falta campo");
}
else
{if (checkBox1.Checked == true) { try { comando.Connection = conexion; conexion.Open(); string SqlAction = "select orden, turno, operador, horainicio, horafin, articulo, totalpiezasok, totalcajas, piezascondefecto, maquina from conteo2 where CONVERT(varchar(10), horafin, 108) >= @horainicio and CONVERT(varchar(10), horafin, 108)<= @horafin and orden = @orden and turno = @turno and maquina = @maquina "; // "SELECT MOLDE, PROYECTO, ITEMPARTE, COLOR, SNP FROM PARTE WHERE ITEMPARTE = @ITEMPARTE"; SqlCommand cmd = new SqlCommand(SqlAction, conexion); cmd.Parameters.AddWithValue("@orden", TXTORDEN\_PRODUCCION.Text); cmd.Parameters.AddWithValue("@turno", TXTTURNO.Text); cmd.Parameters.AddWithValue("@maquina", TXTMAQUINAS.Text); cmd.Parameters.AddWithValue("@horainicio", TXTHORAINICIO.Text); cmd.Parameters.AddWithValue("@horafin", TXTHORAFIN.Text); } conexion.Close(); } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } MessageBox.Show("selecciono ok produccion"); } if (checkBox2.Checked == true) { MessageBox.Show("selecciono paros"); } if (checkBox1.Checked == false & checkBox2.Checked == false) {
the Question is, as can I load the data back my search datagrid
-
the Question is, as can I load the data back my search datagrid
-
the Question is, as can I load the data back my search datagrid
Yes you can. Loading the DataGrid is not a one time only operation.
This space for rent