✅ Using SQLite with C#
The next project of the C# Academy is creating a habit tracker. I'm a little confused on the SQLite aspect of it as I can't seem to get the statement right. I've watched a basic tutorial video https://www.youtube.com/watch?v=oeuTw00F1as&t=725s and I'm using various stack overflows (that make sense) to get my sql working. I have some SQLite knowledge from working with Python, it just seems to be a smidge different.
I got some of this code from https://stackoverflow.com/questions/19479166/sqlite-simple-insert-query and https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/?tabs=visual-studio however when I run my code
I get the problem on my
SaveEntry()
> insertSQL.Parameters.Add(newHabit.Name);
=> Unable to cast object of type 'System.String' to type 'System.Data.SQLiteParameter'
and I'm not entirely sure why? thanks1 Reply
I was able to fix the issue by using AddWithValue instead of just Add. Never mind.