On Wed, 24 Feb 2010 13:31:52 -0000, "Nick Shaw"
<nick.s...@citysync.co.uk> wrote:
>Ah ok, in that case a 3rd party interface would probably be quickest for
>you. :)

Thanks. For those interested, using the above open-source wrapper,
here's how to 1) create a new SQLite database file, 2) create a new
table if it doesn't exist, 3) insert a record, and 4) select all the
records from this table into a RichText widget:

==========
'After running the installer and
'checking Project > Add Ref : System.Data.SQLite

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
        Dim SQLconnect As New SQLite.SQLiteConnection()
        Dim SQLcommand As SQLite.SQLiteCommand

        SQLconnect.ConnectionString = "Data Source=test.sqlite;"
        SQLconnect.Open()

        SQLcommand = SQLconnect.CreateCommand

        'SQL query to Create Table
        SQLcommand.CommandText = "CREATE TABLE IF NOT EXISTS foo(id
INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, description TEXT, image
BLOB);"
        SQLcommand.ExecuteNonQuery()

        SQLcommand.CommandText = "INSERT INTO foo (title) VALUES
('something')"
        SQLcommand.ExecuteNonQuery()

        SQLcommand.CommandText = "SELECT id,title FROM foo"
        Dim SQLreader As SQLite.SQLiteDataReader =
SQLcommand.ExecuteReader()
        RichTextBox1.Clear()
        While SQLreader.Read()
            RichTextBox1.Text &= String.Format("ID = {0}, MYVALUE =
{1}", SQLreader(0), SQLreader(1)) & vbCrLf
        End While

        SQLcommand.Dispose()
        SQLconnect.Close()
    End Sub
==========

Thanks.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to