Orange, could you explain your situation better?
From what I understand, you have a single screen application and in this there are Textbox and Combobox fields, and you need to create a query to the database with these fields, when these are filled, this is it?
If yes, a simple idea.
Use an if to identify which Text or Combo has been filled or selected and fill in the field TAG with the table column name.
Ex:
private void DefineNomeCampos()
{
comboBox1.Tag = "COL_TIPOPESSOA";
textBox1.Tag = "COL_NOMEPESSOA";
}
private void PreencheQuery()
{
StringBuilder sbSelect = new StringBuilder();
StringBuilder sbWhere = new StringBuilder();
sbSelect.Append("Select ");
if (!string.IsNullOrEmpty(textBox1.Text))
{
sbSelect.Append(textBox1.Tag + ",");
sbWhere.Append(textBox1.Tag + "=" + textBox1.Text + ",");
}
if (Convert.ToInt32(comboBox1.SelectedValue) != -1)
{
sbSelect.Append(comboBox1.Tag + ",");
sbSelect.Append(comboBox1.Tag + "," + comboBox1.SelectedText + "," );
}
}
explains one thing to me, how is it that these fields are added in the research part?
– Marcelo Diniz
through another form, in another section of the website
– Laranja Mecânica