Strange SQLite behaviour

Discussion in 'Questions (Windows Mobile)' started by ghale, Jul 23, 2009.

  1. ghale

    ghale Active Member Licensed User

    Issue deleting data from SQLite table

    Hello eveybody,
    I've noticed that if I fill a database table, delete it and fill it again, in the database I find 2 copies of the same data.
    If I delete and fill again the same table, I'll find 3 copies of the data and so on.

    It's only my issue?

    To fill the database I use
    -----------
    ' Start transaction
    Connection.BeginTransaction

    For i = 0 To alWords.Count-1
    strQuery = "INSERT INTO tablename (ID, Item, Item) VALUES (null, '" & alWords.Item(i) & "', 1)"
    Command.CommandText = strQuery
    Command.ExecuteNonQuery
    Next i

    ' End transaction
    Connection.EndTransaction
    -----------

    To clear the tale I use:
    -----------
    ' Start transaction
    Connection.BeginTransaction

    Command.CommandText = "DELETE FROM tablename"
    Command.ExecuteNonQuery

    ' End transaction
    Connection.EndTransaction
    -----------

    WHY the items in the table are not deleted?
    I'm locked here from 2 hours without a solution!

    If I close and reopen the application, all data is deleted!

    Someone can help me, please?

    Thanks,
    bye,
    Piero
     
    Last edited: Jul 23, 2009
  2. Erel

    Erel Administrator Staff Member Licensed User

    I've unsuccessfully tried to reproduce this problem.
    This code uses the same column name twice:
    Code:
    strQuery = "INSERT INTO tablename (ID, Item, Item) VALUES (null, '" & alWords.Item(i) & "', 1)"
    Can you post a small source which demonstrates this problem?
     
  3. ghale

    ghale Active Member Licensed User

    tablename, item and item are dummy names to replace with correct names

    I've solved using array, I'll post a sample source with the issue
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice