public List <string> ValaszLekerdez() { KerdesRaktar kr = KerdesRaktar.getInstance(); List <string> valaszok = new List <string>(); string connectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};" + "DBQ=" + Environment.CurrentDirectory + @"\Fajlok\DB\kerdesadatbazis.xlsx" + ";ReadOnly=0;"; string queryString = "SELECT * FROM [Valaszok$]"; using (OdbcConnection connection = new OdbcConnection(connectionString)) { OdbcCommand command = new OdbcCommand(queryString, connection); try { connection.Open(); OdbcDataReader reader = command.ExecuteReader(); while (reader.Read()) { valaszok.Add((string)reader[0]); } reader.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(valaszok); } }
public static KerdesRaktar getInstance() { if (uniqueInstance == null) { uniqueInstance = new KerdesRaktar(); } return(uniqueInstance); }