views:

171

answers:

1

I'm using flex to develop my first desktop app and I'm working with sqlite for the first time as well.

I'm creating my database and all the tables just fine, but I would also like to add a few rows of data into a couple of the tables so the information is present on first install.

The only problem I'm having is every time I run the program it keeps inserting the same data over and over again.

here's what I'm trying, but it doesn't seem to be working.

            stmt.text = "CREATE TABLE IF NOT EXISTS tbl_breed ("+" breed_id INTEGER PRIMARY KEY AUTOINCREMENT, "+"  breed_breed TEXT)";
            stmt.execute();
            stmt.text = "INSERT OR IGNORE INTO tbl_breed (breed_breed)"+" VALUES ('Test')";
            stmt.execute();

thanks!

+1  A: 

Ok so i figured it out... I guess you have to hard code the the primary key id value.

here what I had to do.

            stmt.text = "CREATE TABLE IF NOT EXISTS tbl_breed ("+" breed_id INTEGER PRIMARY KEY AUTOINCREMENT, "+"  breed_breed TEXT)";
            stmt.execute();
            stmt.text = "INSERT OR IGNORE INTO tbl_breed (breed_id,breed_breed)"+" VALUES ('1','test')";
            stmt.execute();
Adam