in MS ACCESS Request
SELECT SalesByTYPE.TYPE, SalesByTYPE.KILK, SalesByTYPE.WART FROM SalesByTYPE;
returns such a set:
TYPE KILK WART
LD 4000 3000
HD 2000 7000
I want to get the same in C #, my code
private static string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=tgdb.accdb;Jet OLEDB:Database Password = pwd;"; using (OleDbConnection conn = new OleDbConnection(connString)) { conn.Open(); SQL = "SELECT * FROM SalesByTYPE"; using (OleDbCommand comm = new OleDbCommand(SQL, conn)) { using (OleDbDataReader reader = comm.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { answer += $"{reader[0]} :\t{reader[1]} ,\t{reader[2]} .\n"; } Console.WriteLine(answer); } else // { answer = $"Error During Getting The Database Answer"; Console.WriteLine(answer); } } } } As a result of code execution I get:
LD 6000 10,000
those. the first cell of the first row and the total values of the columns. But why and how to fix it?
SELECT * FROM SalesByTYPEdoes not take into account the order - Aleksandr H....SalesByTYPE.TYPE, SalesByTYPE.KILK, SalesByTYPE.WART...), then everything works correctly? - Artyom Okonechnikov