A
A
August Kuk2021-07-01 06:08:45
SQLite
August Kuk, 2021-07-01 06:08:45

Does Unity have something similar to ExecuteScalar?

Hello, please tell me if there is something similar to ExecuteScalar? I'm trying to make an entrance. I
wrote such a code, but apparently they don't prescribe it in the unit, please tell me how it will be more correct?

public void GetDB()
    {
        conn();
        try
        {
            string log= Inputlog.text.ToString();
            string _pass = Inputpass.text.ToString();

            cmd_db = new SqliteCommand("Select Password from User Where login='" + log+ "'");
            if (cmd_db.ExecuteScalar() != null)
            {
                if (cmd_db.ExecuteScalar().ToString() == _pass)
                {
                    cmd_db2 = new SqliteCommand("Select id from User Where  log='" + log+ "'");
                   int id = Convert.ToInt32(cmd_db2.ExecuteScalar());
               
                }
                else
                {
                   print("Неверный пароль!");
                }
            }
            else
            {
                  print("Неверный логин!");
            }

        }
        catch (Exception ex)
        {
          print(ex.ToString());
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2021-07-01
@GavriKos

I'm not sure that work with SQL is generally included in the dotnet unit implementation. Therefore, either look for a compatible library, or work through some api with the base and not directly.

G
GFX Data, 2021-07-01
@ShockWave2048

ExecuteScalar() and the SQL library is not unity or .NET specific, should work.
If it doesn't work, why didn't they show the error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question