K
K
kolya1122020-11-22 13:44:33
C++ / C#
kolya112, 2020-11-22 13:44:33

MySQL C# Windows Forms how to do?

Please help, I made a SELECT query to the table and the name of the element in the table, now I need to extract the value of the "urlimage" element from there and put it in the string variable.

string newstitle = "";
            string newsdesc = "";
            string newsurl = "";
            string newsimageloc = "";

            /*MySqlCommand command = new MySqlCommand("SELECT `title` FROM `launchernews` WHERE `id` = 1", db.GetConnection());
            object result = command.ExecuteScalar();
            newstitle = Convert.ToString(result);
            MySqlCommand command1 = new MySqlCommand("SELECT `description` FROM `launchernews` WHERE `id` = 1", db.GetConnection());
            object result1 = command1.ExecuteScalar();
            newsdesc = Convert.ToString(result1);
            MySqlCommand command2 = new MySqlCommand("SELECT `url` FROM `launchernews` WHERE `id` = 1", db.GetConnection());
            object result2 = command.ExecuteScalar();
            newsurl = Convert.ToString(result2);*/
            MySqlCommand command3 = new MySqlCommand("SELECT `urlimage` FROM `launchernews` WHERE `id` = 1", db.GetConnection());

            //adapter.SelectCommand = command;
            //adapter.SelectCommand = command1;
            //adapter.SelectCommand = command2;
            adapter.SelectCommand = command3; // еррор адаптера тут, из-за того, что значение - нуль.
            //adapter.Fill(newstable);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2020-11-22
@vabka

https://docs.microsoft.com/en-us/dotnet/framework/...
But I was moved to something higher level.
- Dapper, for SQL lovers
- EF Core, for LINQ lovers and change tracker.
- linq2db, for fans of LINQ and non-fans of the change tracker

B
BasiC2k, 2020-11-22
@BasiC2k

Here: https://o7planning.org/ru/10517/working-with-mysql...
everything is very well written.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question