SQLite Insert Into

Scottintexas

Well-known member
Joined
Jun 21, 2018
Messages
47
Location
Texas
Programming Experience
5-10
I keep getting "Insufficient parameters supplied to the command" exception when running the code below. I have tried several versions of code with the same result. Searching on line has given me hundreds of examples of this exception, but they have all been simply typos or they used another of the methods I have tried. It must be something blatantly simple!

C#:
    public void PopulateTable()
    {
        using (SQLiteConnection con = new($"Data Source ={sqliteDB}"))
        {
            con.Open();
            string[] files = Directory.GetFiles(FolderPath);
            foreach (string filepath in files)
            {
                string filename = Path.GetFileName(filepath);
                var cmd = con.CreateCommand();
                cmd.CommandText = "INSERT INTO Files (FileName, FilePath) VALUES (@Filename, @FilePath)";
                cmd.Parameters.AddWithValue("@FileName", filename);
                cmd.Parameters.AddWithValue("@FilePath", filepath);
                cmd.ExecuteNonQuery();
            }
        }
    }

Thank you for looking.
 
@FileName vs @Filename
 
Solution

Latest posts

Back
Top Bottom