in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Creating a new SQLite database file

Last post 12-26-2009 11:46 AM by BlueRaja. 22 replies.
Page 2 of 2 (23 items) < Previous 1 2
Sort Posts: Previous Next
  • 01-19-2007 3:29 PM In reply to

    Re: Creating a new SQLite database file

    Actually, I found that using System.IO.File.Create creates an unusable file vs. SQLiteConnection.CreateFile that works well.
  • 11-08-2008 11:45 AM In reply to

    • Eluim
    • Top 50 Contributor
    • Joined on 10-06-2008
    • Posts 28

    Re: Creating a new SQLite database file

     AND... how can I create a sqlite database including the table structure of another sqlite database ?

  • 11-09-2008 11:49 AM In reply to

    Re: Creating a new SQLite database file

    System.IO.File.Copy(oldDatabase, newDatabase)

  • 06-16-2009 12:29 AM In reply to

    Re: Creating a new SQLite database file

     I am trying to make sqlite create a fully working dbase if there is no db file for whatever reason. However the following statement gives errors about the auto increment part.

    CREATE TABLE Actor ([Actor_ID] bigint PRIMARY KEY NOT NULL AUTO_INCREMENT, [Last_Name] NVARCHAR(50) NOT NULL, [First_Name] NVARCHAR(50) COLLATE NULL

     Do i actually need the autoincrement or is that done automatically. in normal sql create statements i see either the auto increment of the identity parameter but that also gave an error.

     

     

  • 06-16-2009 12:39 AM In reply to

    Re: Creating a new SQLite database file

    You may find it worthwhile to study the SQLite FAQ (http://www.sqlite.org/faq.html). The very first question discusses auto-increment fields. Also, a scan of the SQLite language syntax (http://www.sqlite.org/lang.html) should help you compose proper SQL for this product.
  • 06-17-2009 4:17 AM In reply to

    Re: Creating a new SQLite database file

    I just noticed something i don't really get. I added a new record to the table Actor (i'm making a personal movieDB) and i used the auto generation of the ID to make a new unique ID. This was the first record in the table so naturally it was given the value 0. If i however try to delete the record using that ID nothing happens. It is as if the value in the database is not really a normal 0 and thus the ID's don't match up.

    The table itself is very basic. ID(bigint), Last_Name(nvarchar), First_Name(nvarchar)

    Using this statement to get the value of an ID it returns the value '0' 

    SELECT     Actor_ID
    FROM         Actor
    WHERE     (Last_Name = 'test')

    Therefor i input the value in the next query and every time i get the message '0 rows affected by last query'

    DELETE FROM Actor
    WHERE     (Actor_ID = '0')

     I tried adding a record with ID 0 manually and there was no poblem whatso ever deleting it.

    What am i missing here?

  • 06-17-2009 4:42 AM In reply to

    Re: Creating a new SQLite database file

     never mind i found it. something went wrong with the adding of a record and the value wasn't really '0' but instead it was 'NULL'

  • 12-26-2009 11:46 AM In reply to

    Re: Creating a new SQLite database file

    Just a note:  If the directory does not exist, connection.open() will fail with the rather vague SQLiteException "Unable to open the database file"
Page 2 of 2 (23 items) < Previous 1 2
Powered by Community Server (Commercial Edition), by Telligent Systems