Hello every one i have a small doubt i am inserting some hex value into sqlite db but i am getting a unrecognized token error while inserting value like 000c, 03f4 , 038b but when i am inserting values like 0017 , 0023 , 0384 etc there is no error the data is saved properly to the db... as per my analysis only when there is some alphabet in the hex value i am getting a unrecognized token error.
when there is only numbers in the value it is inserted into the data base.
this is the part of code where i am saving the data into db.
if(temperatureHexdata.count()>=200)
{
temperatureHexdata.
append(QTime::currentTime().
toString("hh:mm:ss"));
m_query.exec("begin transaction Trans");
QString newsQuery
= "insert into allhexdata";
newsQuery += " values (";
for(int q = 0; q < temperatureHexdata.count() && q<200;q++)
{
newsQuery
+= QString("%1").
arg(temperatureHexdata
[q
]) + ", ";
}
newsQuery
+= "'" + QString("%1").
arg(temperatureHexdata
[200]) + "', ";
newsQuery.remove(newsQuery.length() - 2, 2);
newsQuery += ")";
//qDebug() << temperatureHexdata;
qDebug() << "Query=" << newsQuery;
if(!m_query.exec(newsQuery))
{
qDebug() << m_query.lastError().text();
}
m_query.exec("commit transaction Trans");
temperatureHexdata.clear();
}
if(temperatureHexdata.count()>=200)
{
temperatureHexdata.append(QTime::currentTime().toString("hh:mm:ss"));
m_query.exec("begin transaction Trans");
QString newsQuery = "insert into allhexdata";
newsQuery += " values (";
for(int q = 0; q < temperatureHexdata.count() && q<200;q++)
{
newsQuery += QString("%1").arg(temperatureHexdata[q]) + ", ";
}
newsQuery += "'" + QString("%1").arg(temperatureHexdata[200]) + "', ";
newsQuery.remove(newsQuery.length() - 2, 2);
newsQuery += ")";
//qDebug() << temperatureHexdata;
qDebug() << "Query=" << newsQuery;
if(!m_query.exec(newsQuery))
{
qDebug() << m_query.lastError().text();
}
m_query.exec("commit transaction Trans");
temperatureHexdata.clear();
}
To copy to clipboard, switch view to plain text mode
pls tell me if i am doing something wrong. ..
thank you
Bookmarks