I have to make a select statement on a database and than compare the results with a text file using only C# in Visual Studio. If the text file has a bigger value than the record in the database, the program returns the value from the text file, and if the database record has a bigger value, the program returns the value from the database. The results are added to a list being a class WynikPorownania{}. The user types in the file an index of a product and the value(in this case the value is it's availability condition).

For example:

The textfile says this:

WYR\_WR\_CZ1=12

VIDIS\_JIMU\_BOX=3

REREK\_KOTEK\_T=5

In the database, theses indexes are connected to an availability condition like this

WYR\_WR\_CZ1=-1.0000

VIDIS\_JIMU\_BOX=-13.0000

REREK\_KOTEK\_T=0.0000

Now the program should return the bigger value in a list being the WynikPorownania{} class.

For now, I managed to do this much: I took every record from the select query and put it in to a list as a class. I have a function that checks the "standysp"(availability condition) for a specified index, and I asigned the text file value to a string. I think that it could be done maybe with this "zwr" function and maybe a loop but I don't really know where to go from now on. This is my code for now:

```
    using System;
using FirebirdSql.Data.FirebirdClient;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace dokselect
{
    class indexstan
    {
        public string index;
        public double standysp;
    }

    class WynikPorownania
    {
        public string Indeks;
        public int Ilosc;
    }
    class Program
    {
        public static void Main()
        {
            ///////CONNECTION

            string conn = "database=C:/PCBiznes/BAZA/IXION2_LOGMAG.FB;user=SYSDBA;password=masterkey;DataSource=192.168.24.112;Port=3050";
            FbConnection myConnection = new FbConnection(conn);
            FbDataReader myReader = null;

            string sql = "select KARTOTEKA.indeks,STANMAG.standysp FROM kartoteka JOIN stanmag using(ID_KARTOTEKA);";
            FbCommand myCommand = new FbCommand(sql, myConnection);

            myConnection.Open();
            myReader = myCommand.ExecuteReader();

            ///////LIST lista1
            List<indexstan> lista1 = new List<indexstan>();
            double standysp;
            string index;
            while (myReader.Read())
            {
                index = myReader[0].ToString();
                standysp = Convert.ToDouble(myReader[1]);
                lista1.Add(new indexstan { index=index, standysp=standysp });
                //Console.WriteLine(myReader[0].ToString());
            }
            myConnection.Close();
            Console.WriteLine(lista1.Count);

            //RETURN STANDYSP FUNCTION
            double zwr(string myIndex)
            {
                var result = lista1.FirstOrDefault(lista1 => lista1.index == myIndex).standysp;
                return result;
            }
            zwr("EMPIS_DESKA_FASOLKA");

            //READ FROM TXT
            string path = "C:/Users/Praktykant/Documents/textdocs/dok1.txt";
            string plik = File.ReadAllText(path);
            //Console.WriteLine(plik);
            StreamReader objReader = new StreamReader(path);

            myConnection.Close();
        }
    }

```