Scottintexas
Well-known member
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!
Thank you for looking.
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.