I'm trying to read take the idphone from the phone table, but the reader1 collects the data from this table rarely and almost always he does not.
Corroborating that the data I am looking for exists in said table with the search pattern.
for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
{
Db query = new Db();
query.Query("INSERT INTO phone(meid,iccid) VALUES('" + dataGridView2.Rows[i].Cells["ICCID"].Value +
"','" + dataGridView2.Rows[i].Cells["MEID"].Value + "')");
This is the first reader and if it collects the data that I need from the database
MySqlCommand cmd = new MySqlCommand("SELECT idphone FROM phone_atrribute WHERE sku='" + dataGridView2.Rows[i].Cells["SKU"].Value + "'", GetConexion());
MySqlDataReader reader = cmd.ExecuteReader();
This is the second and the one that is giving me problems the data is an integer and sometimes picks it up but it is very rare that it happens, I can not see why it works sometimes and sometimes not.
MySqlCommand cmd1 = new MySqlCommand("SELECT idphone FROM phone WHERE meid='" + dataGridView2.Rows[i].Cells["MEID"].Value + "'", GetConexion1());
MySqlDataReader reader1 = cmd1.ExecuteReader();
Here I try to insert the data collected by the reader and the reader1 in the database, but since the reader1 does not collect the data this is not executed.
if (reader.Read() && reader1.Read())
{
int phone = reader.GetInt32(0);
int attribute = reader1.GetInt32(0);
query.Query("INSERT INTO phone_inventary(phone,phone_attribute) VALUES('"+phone+"','"+attribute+"')");
reader.Close();
reader1.Close();
}
}