abdujalil  chuliev

abdujalil chuliev

  • NA
  • 400
  • 41.4k

foreach

Sep 4 2015 6:38 AM
Hello, the method given below is returning value only from the last rows
of Arrive_Img_ID and Leave_Img_ID. But four image ID exist in each column.
What should I do?

private string getImage_ID()
{
MySqlConnection con = new MySqlConnection(constr);
con.Open();
MySqlCommand cmd = new MySqlCommand("Select Arrive_Img_ID,Leave_Img_ID from register where Students_ID='" + getStudent_ID() + "'");
cmd.Connection = con;
MySqlDataReader reader = cmd.ExecuteReader();
string i = null;
while (reader.Read())
{
foreach (DbDataRecord s in reader)
{
i = reader["Arrive_Img_ID"].ToString();
i = reader["Leave_Img_ID"].ToString();
}
}
reader.Close();
return i;
}

Answers (6)