2 Replies - 3917 Views - Last Post: 12 December 2011 - 02:55 PM Rate Topic: -----

Topic Sponsor:

#1 Roblobob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 01-May 09

Learning to use SQLite with C#

Posted 01 October 2011 - 03:19 PM

I am attempting to write an experimental client type application using C# and the app will require a small to medium sized database. I only need a local database so am thinking SQLite will suite my needs better than say, MySQL.

The problem is this. I have moderate experience programming in C# but little experience with databases. Putting a C# app and a database together is proving very difficult for me as I have never done it before.

I have experimented with sqlite3.exe in the command line and that's straight forward enough.

I have run through the following tutorials but I am lost and I don't really understand them: -
http://www.mikedunca...tnet-in-3-mins/
http://brennydoogles...te-with-csharp/

I know in theory what I want to do but I have no idea how to do it.

I'm not sure how to attack this. Can someone with some experience give me some pointers?

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Learning to use SQLite with C#

#2 modi123_1  Icon User is online

  • Suiter #2
  • member icon


Reputation: 3542
  • View blog
  • Posts: 14,954
  • Joined: 12-June 08

Re: Learning to use SQLite with C#

Posted 02 October 2011 - 09:52 AM

Quote

I know in theory what I want to do but I have no idea how to do it.

Well - what do you want to do? I am bad at guessing games for intent of programs. ;)

Your basic concept is you:
read data from the database with SELECT statements.
insert new rows into the database with INSERT
modify rows with UPDATE
remove rows with DELETE

The gist to read data is:

write your SQL statement as a string.
create a connection to your database
open said connection.
create a sqlcommand object from the sql string and the connection
execute the sqlcommand object and have it fill a sql adapter or datareader.
close the connection to the database
parse through your sqladapter or datareader for your rows.

the insert/update/delete follow the same route but instead of using a sqldata adapter you use the sqlcommand object's "execute non reader" or some similar method.

Also wrap everything in a try/catch.
Was This Post Helpful? 0
  • +
  • -

#3 brennydoogles  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 59
  • Joined: 23-June 09

Re: Learning to use SQLite with C#

Posted 12 December 2011 - 02:55 PM

What kind of issue are you having? The second link you posted is from my blog, so if there is any part of my tutorial I could clarify for you I would be more than happy to!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1