Click here to Skip to main content
14,644,614 members
Rate this:
Please Sign up or sign in to vote.

Suppose there is a database and a table with 4 records

The database closes and I close the program

When I open the program, I establish a connection to the database

Now how do I get the table object so I can insert or delete it?

string dpPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "user.db3"); //Create New Database  
db = new SQLiteConnection(dpPath);
Table1 tbl= db.Table<Table1>();

Error: cannot implicitly convert type SQLite.TableQuery<createatable.table1> to CreateaTable.Table1.

What I have tried:

I tried the above code and saw the mentioned error
Updated 26-Jul-20 20:42pm
Richard MacCutchan 26-Jul-20 12:52pm
It looks like you are using a different name to the one that is declared. But we cannot see the rest of the code so that is a guess.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Table1 tbl= db.Table<Table1>();

Return datatype of db.Table<Table1>() is not of type Table1

You need to assign it to correct datatype or to var and then accordingly use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100