Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2006
    Posts
    5,380

    sqlite help needed

    ok, iv broken out the sqlite plugin after watching tigg's video tuts and already iv hit a road block

    i want to only add a item to the database if it dosent already exist, so like no duplicate entrys can be made based on a listbox items text,

    so how would i compair a string of text to either a database column or the listbox name (as thay will both contain the same data) and only add the string to the database if the same string isent already present


    this is what iv come up with, and guess what.....it dosent work, lol
    isCB = Clipboard.IsTextAvailable();
    if isCB then
    cbText = Clipboard.GetText();
    if cbText ~= tbReturn.Data["data"] then
    AddtoDB()
    end
    end
    am i even half on the right track, do i need a loop, if so, how do i format it

    thanks in advance for any help
    Open your eyes to Narcissism, Don't let her destroy your life!!

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Where do you not want to have the duplicate? Is this in the SQLite database or in the listbox? If it is the listbox you can loop through the listbox and compare the text.

    strcompare = "texttocheck";
    bnew = true;
    for x = 1, ListBox.GetCount do
    --select item one
    --get the text to compare
    --compare it to strcompare
    if it matches then bnew = false end
    end

    or something like that anyway.

    For SQLite on the version that IR uses you cannot define a column as being unique so you what you can do is do a query for the text you have and if nothing is returned then you can add the file. Depending on your structure you can also perform an INSERT or REPLACE on the data and it willl either insert a new record or replace the one that is there.

    HTH
    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  3. #3
    Join Date
    Apr 2004
    Location
    Vancouver, Canada
    Posts
    1,790
    Actually you can make a column unique in the version that AMS uses.

    Code:
    SQLite.Query(db, "CREATE TABLE Notes(NoteID integer primary key, Note text UNIQUE)")
    If you try saving a duplicate it will return error number 30019.
    Dermot

    I am so out of here

  4. #4
    Join Date
    May 2006
    Posts
    5,380
    Hi Tigg, well it dosent realy matter what i query with, the database or the listbox because thay both cotain the same data,

    maybe i should explain a little bet better, i want to get text from the clipboard and enter it in to the database and the listbox, but i want to fire this in a page timer, so i want to set the condition that if the text is already in the listbox then dont add it to the database

    iv got all my other functions working ok and i have a button that adds the data to both the DB and the LB, but as i say i want it to fire in page timer so searching the listbox is the way to go i think or it just keeps adding the same text over and over again

    i'll have a crack at it with the code you provided and see if i can make a working function
    Open your eyes to Narcissism, Don't let her destroy your life!!

  5. #5
    Join Date
    May 2006
    Posts
    5,380
    ah, dermot, we both posted at the same time, ill try both methoods and see what i get
    Open your eyes to Narcissism, Don't let her destroy your life!!

  6. #6
    Join Date
    May 2006
    Posts
    5,380
    well stone the crows, that was easy it works like a dream now, thanks Dermot

    i now copy any text and stright away its added to the DB and LB only once, great job, this little app is nearly finished already

    between Tigg and Dermot iv learned so much about the sqlite plugin today, i wonder where users like myself would end up without such a great support team

    To all the guys that make this forum such a great support site, THANK YOU (you know who you are )
    Open your eyes to Narcissism, Don't let her destroy your life!!

  7. #7
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Quote Originally Posted by Dermot View Post
    Actually you can make a column unique in the version that AMS uses.

    Code:
    SQLite.Query(db, "CREATE TABLE Notes(NoteID integer primary key, Note text UNIQUE)")
    If you try saving a duplicate it will return error number 30019.
    Good to know. I had not played much with UNIQUE on the SQLite so I didn't know how well it worked with the table being stored as ascii. I know that the definations for the columns doesn't do much other than provide a guideline for columns with the one exception of integer primary key.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

Similar Threads

  1. SQLite plugin problem
    By swilk in forum AutoPlay Media Studio 5.0
    Replies: 3
    Last Post: 11-10-2009, 05:22 PM
  2. SQLite database in MEMORY only!
    By Intrigued in forum AutoPlay Media Studio 5.0
    Replies: 5
    Last Post: 10-23-2009, 07:49 PM
  3. How to convert access database to sqlite database.
    By sside in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 07-22-2008, 07:44 PM
  4. PLUGIN EXAMPLE: SQLite
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 10
    Last Post: 07-14-2006, 06:01 AM
  5. Spotlight: SQLite Actions Plugin
    By Desmond in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 03-12-2004, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts