private void Button3_Click_1(object sender, EventArgs e) { myConnection = new OleDbConnection(connectString); myConnection.Open(); string isvedimas = "SELECT Pavadinimas, Kiekis, Kaina, CPU, Videocard, Memory FROM Stacio ORDER BY ID;"; OleDbCommand command = new OleDbCommand(isvedimas, myConnection); int m = 0; OleDbDataReader reader = command.ExecuteReader(); listBox1.Items.Clear(); while (reader.Read()) { listBox1.Items.Add(reader[0].ToString() + " " + reader[1].ToString() + " " + reader[2].ToString()); if (n == m) { S[m] = new Stacionarus(); S[m].SetPav(reader[0].ToString()); S[m].SetKiek(Convert.ToInt32(reader[1])); S[m].SetKaina(Convert.ToDouble(reader[2])); S[m].SetCPU(reader[3].ToString()); S[m].SetGPU(reader[4].ToString()); S[m].SetMem(Convert.ToDouble(reader[5])); } m++; } n = m; reader.Close(); myConnection.Close(); }
public Admin() { InitializeComponent(); myConnection = new OleDbConnection(connectString2); myConnection.Open(); string isvedimas = "SELECT Pavadinimas, Kiekis, Kaina, CPU, Videocard, Memory FROM Nesio ORDER BY ID;"; OleDbCommand command = new OleDbCommand(isvedimas, myConnection); OleDbDataReader reader = command.ExecuteReader(); n = 0; while (reader.Read()) { N[n] = new Nesiojami(); N[n].SetPav(reader[0].ToString()); N[n].SetKiek(Convert.ToInt32(reader[1])); N[n].SetKaina(Convert.ToDouble(reader[2])); N[n].SetCPU(reader[3].ToString()); N[n].SetGPU(reader[4].ToString()); N[n].SetMem(Convert.ToDouble(reader[5])); n++; } reader.Close(); myConnection.Close(); myConnection2 = new OleDbConnection(connectString); myConnection2.Open(); string isvedimas2 = "SELECT Pavadinimas, Kiekis, Kaina, CPU, Videocard, Memory FROM Stacio ORDER BY ID;"; OleDbCommand command2 = new OleDbCommand(isvedimas2, myConnection2); OleDbDataReader reader2 = command2.ExecuteReader(); m = 0; while (reader2.Read()) { S[m] = new Stacionarus(); S[m].SetPav(reader2[0].ToString()); S[m].SetKiek(Convert.ToInt32(reader2[1])); S[m].SetKaina(Convert.ToDouble(reader2[2])); S[m].SetCPU(reader2[3].ToString()); S[m].SetGPU(reader2[4].ToString()); S[m].SetMem(Convert.ToDouble(reader2[5])); m++; } reader2.Close(); myConnection2.Close(); }