TB007
Member
- Joined
- Aug 13, 2022
- Messages
- 24
- Programming Experience
- Beginner
I have the following SQLite database table
When I load the WPF app I run the ff() method shown below
But getting the error (on the line
Please help
When I load the WPF app I run the ff() method shown below
C#:
public static string dbloc = @"Data Source=MYDATA.db";
internal static SQLiteConnection GetConnection() { return new SQLiteConnection(dbloc);}
public static Dictionary<int, string> getState = new Dictionary<int, string>();
public static string query= "select distinct GSTIN, STATE from StateWiseGST";
public static void ff()
{
using (var con = GetConnection())
{
con.Open();
using (SQLiteCommand cmd = new SQLiteCommand(query, con))
{
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
getState[(int)reader["GSTIN"]] = (string)reader["STATE"];
}
}
}
}
}
But getting the error (on the line
getState[(int)reader["GSTIN"]] = (string)reader["STATE"];
):System.Windows.Markup.XamlParseException: 'The invocation of the constructor on type 'Test.Window1' that matches the specified binding constraints threw an exception.' Line number '3' and line position '99'. ---> System.InvalidCastException: Specified cast is not valid.
Please help