Per Erik Strandberg /cv /kurser /blog

I just learned that sqlite and Csharp can walk hand in hand. I just downloaded sqlitegindings from [1] and followed a VisualBasic tutorial to it from [2] and following my own tutorial to Python in [3] I made this sort of minimal example to the two:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SQLite;

namespace sqlite_test
    class Program
        static void Main(string[] args)
            SQLiteConnection con;
            SQLiteCommand com;
            SQLiteDataReader reader;

            con = new SQLiteConnection("Data Source=C:\\tmp\\text.db");

            com = con.CreateCommand();
            com.CommandText = "CREATE TABLE IF NOT EXISTS test(id int, data text)";

            com.CommandText = "INSERT INTO test(id, data) VALUES(1, 'hello')";

            com.CommandText = "SELECT * FROM test";

            reader = com.ExecuteReader();
            while (reader.Read())
                Console.WriteLine("{0}, {1}", reader[0], reader[1]);


See also Csharp And Sqlite In Mono.

This page belongs in Kategori Programmering.