This code is partially working. It gives me the first and second columns in the first row. But the SQL query result has 3 rows, and I want to read them too.
How can I do that? Maybe my method is wrong for this but I couldn't figure it out.
private void GetDataAN()
{
string sqlAN = "SELECT SUM(Original_Kap_Adeti +Bag_Kap_Adeti), SUM(Original_Kg + Bag_Kg) FROM Antrepo_Form WHERE Antrepo_No LIKE '" + Antrepo_No.Text + "' GROUP BY Form_Tipi";
SqlCommand cmdAN = new(sqlAN, Antrepo_DB.con);
SqlDataReader drAN = cmdAN.ExecuteReader();
while (drAN.Read())
{
Antrepo_Kap.Text = drAN[0].ToString(); //1. row, 1. column
Antrepo_Kg.Text = drAN[1].ToString(); //1. row, 2. column
// Ellecleme_Kap.Text = drAN[0].ToString(); //2. row, 1. column
// Ellecleme_Kg.Text = drAN[1].ToString(); //2. row, 2. column
// Ihracat_Kap.Text = drAN[0].ToString(); //3. row, 1. column
// Ihracat_Kg.Text = drAN[1].ToString(); //3. row, 2. column
}
AN_Kap.Text = (Antrepo_Kap.Text + Ellecleme_Kap.Text + Ihracat_Kap.Text);
AN_Kg.Text = (Antrepo_Kg.Text + Ellecleme_Kg.Text + Ihracat_Kg.Text);
}