Click here to Skip to main content
15,885,048 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello

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
Posted
Updated 26-Jul-20 20:42pm
Comments
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

C#
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900