Пример #1
0
    public static DataTable Select3(string kolona, string tabela, string uslov)
    {
        string where = "";

        if (uslov.Length > 2 && uslov.Substring(0, 3) != "ne,")
        {
            where = " where ";
        }
        else if (uslov.Length > 3 && uslov.Substring(0, 3) == "ne,")
        {
            where = "";
            uslov = uslov.Substring(3);
        }
        else if (uslov.Length == 2)
        {
            where = "";
            uslov = "";
        }
        MySqlConnection  konekcija  = new MySqlConnection(Konekcija.VratiPath3());
        string           sql        = "Select " + kolona + " from " + tabela + " " + where + uslov;
        MySqlCommand     komanda    = new MySqlCommand(sql, konekcija);
        MySqlDataAdapter adapter    = new MySqlDataAdapter(komanda);
        DataTable        dtRezultat = new DataTable();

        adapter.Fill(dtRezultat);

        return(dtRezultat);
    }