开发者

How can I get SQLite to work in C#

开发者 https://www.devze.com 2022-12-23 17:56 出处:网络
I have installed SQLite and am using the wrapper from: http://sqlite.phxsoftware.com/ I have created my database and table in the server explorer in VS2010 but when I create the connection, I don\'t

I have installed SQLite and am using the wrapper from: http://sqlite.phxsoftware.com/

I have created my database and table in the server explorer in VS2010 but when I create the connection, I don't understand what to do from there and how to get it to work.

Can someone provide code examples on how to connect to a db, get a table, insert dat开发者_开发问答a into the table and select data from a table and output it.

I would really appreciate it.

Thanks


Server Explorer is overkill, SQLite is meant to be simple and light. Just use plain code as follows.

SQLiteConnection connection = new SQLiteConnection("Data source=PATH_TO_YOUR_DB;Version=3");
connection.Open();
SQLiteCommand command = connection.CreateCommand();
command.CommandText = "insert into something values (1,2,3)";
command.ExecuteNonQuery();
connection.Close();

Hope it helps.


OK here is what I did (assuming that you have that s**t installed):

1.-right click on server explorer

2.-then click on add conection

3.-on data source click Change then select sqlite

4.-fill out da details

5.-you are done... you can now add datasets....

0

精彩评论

暂无评论...
验证码 换一张
取 消