C# help sqlite blob



  • How does BLOB show in the console? I've been doing this for an hour. system.byte[]

    system.byte[]

    reader[5].tostring - it's a blob field.

    string record = null;
    

    SQLiteDataReader reader;
    SQLiteConnection connection = new SQLiteConnection("Data Source=C:\data;Version=3;New=True;Compress=True;");

    connection.Open();
    SQLiteCommand command = new SQLiteCommand("SELECT * FROM database", connection);
    reader = command.ExecuteReader();

    while (reader.Read())
    {
    record = reader[5].ToString();
    connection.Clone();
    Console.WriteLine(record);
    console.readkey();
    }`


    I'm the one who tried, but it doesn't work. введите сюда описание изображения


    I didn't do anything in the database until I tried the google chrome database. Login Data.

     static void Main(string[] args)
    {

        string record = null;
    
        SQLiteDataReader reader;
    
    
        SQLiteConnection connection = new SQLiteConnection("Data Source=C:\\login data;Version=3;New=True;Compress=True;");
    
    
    
        connection.Open();
        SQLiteCommand command = new SQLiteCommand("SELECT * FROM logins", connection);
        reader = command.ExecuteReader();
    
    
        while (reader.Read())
    
        {
    
            byte[] bytes = (byte[])reader[5];
    
    
    
    
    
                foreach (byte b in bytes)
                  Console .WriteLine (Encoding.Default .GetString    ((byte[])reader[5]));
                Console.ReadKey();
    
    
    
    
            connection.Clone();
    
    
        }
    
    
    
    
    
    }
    

    }


    the blank contains the password, encrypted
    I did it, but I only get symbols in the text.
    введите сюда описание изображения



  • The console can only remove the text. The ToString method is not overloaded and therefore returns the name of the type. Massive Byte needs to be decoded first. If your blob is the text, then the code is right.

    record = Encoding.UTF8.GetString((byte[])reader[5]);
    

    or

    record = Encoding.GetEncoding(1251).GetString((byte[])reader[5]);
    

    If the blob is raw,

    record = Convert.ToBase64String((byte[])reader[5]);
    

    or

    record = BitConverter.ToString((byte[])reader[5]).Replace("-","");
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2