A
A
Andrey Fomin2021-02-08 17:50:21
SQLite
Andrey Fomin, 2021-02-08 17:50:21

How to rework the server code?

Hello!
There is a server and an application, both written in C#, the application sends sql queries to the server, and the server passes these sql queries to the database and they are executed, I managed to implement work with queries that contain INSERT and UPDATE, but it doesn’t work with SELECT.
Here is a piece of server code where an sql query with a SELECT is being processed:

if (message.Contains("SELECT"))
                        {
                            string rtrn = null;
                            SqliteConnection connect = new SqliteConnection("Data source = accounts.db");
                            connect.Open();
                            SqliteCommand command = new SqliteCommand(message, connect);
                            command.ExecuteNonQuery();
                            SqliteDataReader Reader = command.ExecuteReader();
                            while (Reader.Read())
                            {
                                rtrn = Reader["Password"].ToString();
                            }
                            Reader.Close();
                            byte[] nazad = Encoding.UTF8.GetBytes(rtrn);
                            stream.Write(nazad, 0, nazad.Length);
                        }

I'm interested in this piece:
SqliteDataReader Reader = command.ExecuteReader();
                            while (Reader.Read())
                            {
                                rtrn = Reader["Password"].ToString();
                            }
                            Reader.Close();

How can it be changed so that there is no Password indication here?
And one more thing: do I need to create 2 threads for sending data and receiving data, or can I get by with one, but cleared after sending?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2021-02-08
@a63826ndrew

It's just a column name
Reader["Password"]
Well, use Reader[1] // or whatever it is in order, what's the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question