SQLContainer AddItem

Hi Guys,

I just want to know how can i add an item to the database using sqlcontainer. Here is my first code and out of bad luck it does not work. I am having a hard time reading the addressbook demo because of the person bean that is used.

     SQLContainer AddContainer = new SQLContainer(new TableQuery("tbl_grade", connectionPool));
                        AddContainer.setAutoCommit(false);
                        AddContainer.addItem();
                        AddContainer.getItem("ID").getItemProperty("ID").setValue("Grade 4");

Hi,

addItem will return id of the new Item and with that id you can fetch the actual new item, like this:
Object id = AddContainer.addItem();
Item item = AddContainer.getItemUnfiltered(id);
//Play with item
AddContainer.commit();

Thanks Harri
thus the code below will add an item to the database.

    Object ItemID = AddContainer.addItem();
    AddContainer.getItem(ItemID).getItemProperty("ID").setValue("Grade 4");
    AddContainer.commit();

How Can I Update an existing record from the database?

Bonjour,
any modified item of the container will be updated in the database if you perform of commit on the container.