I have a DataTable with two values that are obtained from DataGridView:
- Código
- Denominación
Now, I want to do a query to a Database and get two new values for every code:
- Caract
- Valor
What I'm doing is create a new datatable and store there the values Caract and Valor, so I have to DataTable, one with Código and Denominación and another one with Caract and Valor.
**What you should recommmend me? Introduce the new values in the first datatable or create these two datatables and try to join them.
This is my code:
1) Intranet.list1 have all the codes
2) caracSeleccionadas have all the features.
foreach (DataRow row in Intranet.list1.Rows)
{
for (int i = 0; i < caracSeleccionadas.Count; i++)
{
conexion = new SqlConnection(connString);
conexion.Open();
//la denominación se obtiene de otra tabla
strsql = "";
strsql = strsql + " SELECT CARACT, VALOR";
strsql = strsql + " FROM T_ARTCAR";
strsql = strsql + " WHERE CODIGO = '" + row["Code"].ToString() + "' AND CARACT = '" + caracSeleccionadas[i].ToString() + "'";
System.Diagnostics.Debug.WriteLine(" query: " + strsql);
comando = new SqlCommand(strsql, conexion);
adapter = new SqlDataAdapter(comando);
table = new DataTable();
comando.CommandText = strsql;
table.Columns.Clear();
table.Clear();
adapter.Fill(table);
dtExcelInforme.Rows["Característica"] = "";