0
如何檢查數據庫中是否存在記錄(ContentValues
)?如何檢查記錄是否已經存在?
public void insertData(String ActId,String Dstcode,String Mandicode,String Traderlicno,String licenseId,String licensename,String Gatepassno,String FarmerId,String Farmername,String FarmerFatherName,String CommodityGrpCode,String CommodityCode,String VartyCode,String Cwght,String UntCode,String FnlPrice,String lgndate,String Ip,String dte,String IEMIN0,String ModelNo,String BoardName,String BrandName,String SIMNo)
{
ContentValues cv = new ContentValues();
cv.put(DatabaseHandler.AUCTIONINFO_ActId, ActId);
cv.put(DatabaseHandler.AUCTIONINFO_Dstcode, Dstcode);
cv.put(DatabaseHandler.AUCTIONINFO_Mandicode, Mandicode);
cv.put(DatabaseHandler.AUCTIONINFO_Traderlicno, Traderlicno);
cv.put(DatabaseHandler.AUCTIONINFO_licenseId, licenseId);
cv.put(DatabaseHandler.AUCTIONINFO_licensename, licensename);
cv.put(DatabaseHandler.AUCTIONINFO_Gatepassno, Gatepassno);
cv.put(DatabaseHandler.AUCTIONINFO_FarmerId, FarmerId);
cv.put(DatabaseHandler.AUCTIONINFO_Farmername, Farmername);
cv.put(DatabaseHandler.AUCTIONINFO_FarmerFatherName, FarmerFatherName);
cv.put(DatabaseHandler.AUCTIONINFO_CommodityGrpCode, CommodityGrpCode);
cv.put(DatabaseHandler.AUCTIONINFO_CommodityCode, CommodityCode);
cv.put(DatabaseHandler.AUCTIONINFO_VartyCode, VartyCode);
cv.put(DatabaseHandler.AUCTIONINFO_Cwght, Cwght);
cv.put(DatabaseHandler.AUCTIONINFO_UntCode, UntCode);
cv.put(DatabaseHandler.AUCTIONINFO_FnlPrice, FnlPrice);
cv.put(DatabaseHandler.AUCTIONINFO_lgndate, lgndate);
cv.put(DatabaseHandler.AUCTIONINFO_Ip, Ip);
cv.put(DatabaseHandler.AUCTIONINFO_dte, dte);
cv.put(DatabaseHandler.AUCTIONINFO_IEMIN0, IEMIN0);
cv.put(DatabaseHandler.AUCTIONINFO_ModelNo, ModelNo);
cv.put(DatabaseHandler.AUCTIONINFO_BoardName, BoardName);
cv.put(DatabaseHandler.AUCTIONINFO_BrandName, BrandName);
cv.put(DatabaseHandler.AUCTIONINFO_SIMNo, SIMNo);
database.insert(DatabaseHandler.TABLE_AUCTIONINFO, null, cv);
}
你有問題嗎? – 2014-09-06 10:08:32
運行一個簡單的查詢 - '從TABLE_AUCTIONINFO中選擇AUCTIONINFO_ActId,其中AUCTIONINFO_licenseId = licenseId;'如果光標爲空意味着記錄不存在 – 2014-09-06 10:09:26
您的記錄標準是什麼?有一些id存在或所有columna匹配?如果一行已經存在,你想要做什麼? – laalto 2014-09-06 11:27:51