質問

Could you give me a simple example on how to delete a record from my database using SQLContainer.

I have tried using SQLContainer.Removeid(itemID) but it still won't work. Hope someone can help me.

This is what I have tried:

try {
    SQLContainer DeleteContainer = new SQLContainer(new TableQuery("tbl_grade", connectionPool));
    Object ItemID = "10";
    DeleteContainer.removeItem(ItemID);
    DeleteContainer.commit();
} catch (SQLException ex) {
    ex.printStackTrace();
}
役に立ちましたか?

解決

You need to provide Id of the item as an instance of RowId class.
Try this:
(Assumming Id of the item is of type Integer)

try {
    SQLContainer deleteContainer = new SQLContainer(new TableQuery("tbl_grade", connectionPool));
    RowId itemID = new RowId(new Integer[] { 10 });
    deleteContainer.removeItem(itemID);
    deleteContainer.commit();
} catch (SQLException ex) {
    ex.printStackTrace();
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top