Hello every one i have am trying to insert some 550 channels of data to sqlite db. This is the code i am using to update. every thing is but i am having a problem in the place where i am appending the data into the finaldatabuff, i am trying to increment columncount till 550 and then insert the 550 channels data into the db. But here even after the columncount counter cross's 550, the condition if(columncount == 550) is not satisfied and the query is not executed at all. .. in case i remove the if(columncount == 550) condition all the data is saved into the db but it is repeated.. what do you think is going wrong , why is the if condition not satisfied... ?
void datareceiver::insertdb()
{
timer8->stop();
for(int p = 0; p < temperaturedata.count();p++)
{
QVector<QString> *v111 = new QVector<QString>();
finaldatabuff << v111;
//for(rd = 0 ; rd < 550;rd++)
//{
for(int q = 0; q < temperaturedata[p]->count(); q++)
{
finaldatabuff[finaldatabuff.count()-1]->append(temperaturedata[p]->at(q));
columncount++; // incremented untill 550
}
}
if(columncount == 550) // when columncount=550 insert 550 channels the data into the db .
{
m_query.exec("begin transaction Trans");
for (int i = 0; i < finaldatabuff.count(); ++i)
{
QString sQuery
= "insert into thdata";
sQuery += " values (";
for (int j = 0; j < finaldatabuff[i]->count(); ++j)
sQuery
+= QString("%1").
arg(finaldatabuff
[i
]->at
(j
)) + ", ";
sQuery.remove(sQuery.length() - 2, 2);
sQuery += ")";
q.exec(sQuery);
if(!m_query.exec(sQuery))
{
qDebug() << m_query.lastError().text();
}
}
m_query.exec("commit transaction Trans");
columncount=0;
for(int i = 0; i < finaldatabuff.size(); ++i)
delete finaldatabuff[i];
finaldatabuff.clear();
for(int i = 0; i < temperaturedata.size(); ++i)
delete temperaturedata[i];
temperaturedata.clear();
timer8->start(2000);
}
}
void datareceiver::insertdb()
{
timer8->stop();
for(int p = 0; p < temperaturedata.count();p++)
{
QVector<QString> *v111 = new QVector<QString>();
finaldatabuff << v111;
//for(rd = 0 ; rd < 550;rd++)
//{
for(int q = 0; q < temperaturedata[p]->count(); q++)
{
finaldatabuff[finaldatabuff.count()-1]->append(temperaturedata[p]->at(q));
columncount++; // incremented untill 550
}
}
if(columncount == 550) // when columncount=550 insert 550 channels the data into the db .
{
m_query.exec("begin transaction Trans");
QTime startTime = QTime::currentTime();
for (int i = 0; i < finaldatabuff.count(); ++i)
{
QString sQuery = "insert into thdata";
sQuery += " values (";
for (int j = 0; j < finaldatabuff[i]->count(); ++j)
sQuery += QString("%1").arg(finaldatabuff[i]->at(j)) + ", ";
sQuery.remove(sQuery.length() - 2, 2);
sQuery += ")";
QSqlQuery q;
q.exec(sQuery);
if(!m_query.exec(sQuery))
{
qDebug() << m_query.lastError().text();
}
}
m_query.exec("commit transaction Trans");
columncount=0;
for(int i = 0; i < finaldatabuff.size(); ++i)
delete finaldatabuff[i];
finaldatabuff.clear();
for(int i = 0; i < temperaturedata.size(); ++i)
delete temperaturedata[i];
temperaturedata.clear();
timer8->start(2000);
}
}
To copy to clipboard, switch view to plain text mode
pls help me out tell me what could be going wrong. ..
thank you,
Bookmarks