Q:

Attaching a database in Sqlite using .NET not working

I created a helper class for Sqlite in C# (using Data.SQLite) where I am putting methods like GetTables,GetColumnNames,...
Now I added method AttachDatabase to attach a database but it does not seem to be working.
The code for this method is as follows
    public void AttachDatabase(string path)
    {
        string db_name = "attdb";
        sqlConnection.Open();

        SQLiteCommand scom = new SQLiteCommand(sqlConnection);
        scom.CommandText = "ATTACH '"+path+"' AS " + db_name;

        scom.ExecuteNonQuery();

        sqlConnection.Close();
    }

The method does not throw any exceptions, when I provide a path to a database file.

And to test it I added another method in helper class that is like this
    public List<string> GetAllDatabases()
    {
        List<string> mylist = new List<string>();

        sqlConnection.Open();
        SQLiteCommand scom = new SQLiteCommand("PRAGMA database_list", sqlConnection);
        SQLiteDataReader sreader = scom.ExecuteReader();

        while (sreader.Read())
        {
            string name = (sreader.GetValue(1)).ToString();
            mylist.Add(name);
        }
        sqlConnection.Close();

        return mylist;
    }

After attaching a database, this method returns a list with only main table in it.
What am I doing wrong?

A:

Sqlite does not persist the attached databases. Every time you open and close the connection, the attached databases are forgotten.

