Ejemplo n.º 1
0
void CTempretureImpl::InsertDataToMySql(vector<CTempData*> tempvec)
{
	CDatabase *db = CDbConnect::GetInstance()->getDatabase();
	if (!db->BeginTrans())
		return;
	for (int i = 0; i < tempvec.size(); i++){
		CString sql;
		sql.Format(_T("insert into tempreture(tempreture,time) values('%s','%s')"), tempvec.at(i)->GetTemperature(), tempvec.at(i)->GetTime());
		db->ExecuteSQL(sql);
	}
	db->CommitTrans();

}
Ejemplo n.º 2
0
void CTempretureImpl::InsertDataToMySql(CTempData* temp)
{
	CDatabase *db = CDbConnect::GetInstance()->getDatabase();
	if (!db->BeginTrans())
		return;
	int n = 3;
	while (n--)
	{
		CString sql;
		sql.Format(_T("insert into tempreture(tempreture,time) values('%s','%s')"), temp->GetTemperature(), temp->GetTime());
		db->ExecuteSQL(sql);
	}
	db->CommitTrans();

}