I'm working on an app linked to a local database. What I want, is to show in a form datae from database, but in labels. I created a list of labels, but I get this error at command.Executescalar(), where I try to get the number of rows entered in the dataBase, so the list can create the exact number of rows. Thanks !
int infoCount = (int)command.ExecuteScalar();
var pozitie = 50; //50 pixeli
for (var i = infoCount ; i >= 0; i--)
{
//creez si adaug un nou label in form
Label label = new Label();
label.Text = dataTable.Rows[i][i].ToString();
label.Location = new Point(pozitie, 150);
label.AutoSize = true;
//afisez in form
//adaug in colectie
labels.Add(label);
}
L.E:
var query = "SELECT * FROM grupe WHERE Nume='" + nume + "'";
var command = new SqlCeCommand(query, conn);
var dataAdapter = new SqlCeDataAdapter(command);
var dataTable = new DataTable();
dataAdapter.Fill(dataTable);