W
W
WasTabon2021-06-14 15:37:18
SQL
WasTabon, 2021-06-14 15:37:18

How can I see in the database if new data has been entered?

Just started to delve into it all, so do not hit hard.

if (msg.Text == "/start")
            {
                if (sql.State == ConnectionState.Closed)
                {
                    sql.Open(); //Открываем sql подключение
                    SqlCommand command = new SqlCommand("INSERT INTO Info (Id, Users) VALUES (1, 'OneTwoThree')", sql); 
                    await command.ExecuteNonQueryAsync(); 
                    sql.Close();
                }
            }

60c74d160ce00354832815.png
I made a telegram bot for the test, when you enter / start, in theory, information should be written to the database, but nothing happens. There are no errors, the condition exactly works if (msg.Text == "/start")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oleg_ods, 2021-06-14
@WasTabon

For the future, the ExecuteNonQueryAsync() method returns the number of changed rows in the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question