Hi. I am trying to extract some info from an sql database using code.
objSqlDT.Reset();
objSqlDA.Fill(objSqlDT);
intNrRecords = objSqlDT.Rows.Count;
tmp_strTemp_Matr = new string[intNrRecords, tmp_strTempFields_Vect.Length];
for (int j = 0; j < intNrRecords; j++)
{
for (int k = 0; k < tmp_strTempFields_Vect.Length; k++)
{
//tmp_strTemp_Matr[j, k] = objSqlDT.Rows[j][tmp_strTempFields_Vec[k]].ToString();
strColoana = tmp_strTempFields_Vect[k];
tmp_strTemp_Matr[j, k] = objSqlDT.Rows[j][strColoana].ToString();
}
}
tmp_strTempFields_Vect[k]; contains the name of the fields for which I extract the information.
tmp_strTemp_Matr[j, k] is the matrix which contains all the information for the fielda above.
The thing is that the program generates an error when it reaches this line
tmp_strTemp_Matr[j, k] = objSqlDT.Rows[j][strColoana].ToString();
it generates this error:
An error occured: 'Column 'nameTypeDevice' does not belong to table .'
Of course, it's false , the columns is there, I do not understand why the value cannot be inserted into the matrix.
Thank you!