inserting content in database
Hello I have a simple question .
what is the best way to insert content to a database. What about cutting up the string if the content is to long for field in the database. Is there a flag to set for automatic cutting cause when it is to long te insert fails.
Any idea??
This is my approach:
Code:
if(qstr_textLine.count(";",Qt::CaseInsensitive)== 2){
qstr_textLine.prepend("'");
qstr_textLine.append("'");
int sqlbool=insertquery.exec("INSERT INTO testtbl (field1,field2,field3) "
"VALUES ("+qstr_textLine+")");
}
I use mssql.
Re: inserting content in database
Don't say "I have a simple question", if it is simple, why do you ask? :)
How about using QString::left(...)?
But yet, it is simple :D
Re: inserting content in database
Quote:
Originally Posted by
codeman
Code:
if(qstr_textLine.count(";",Qt::CaseInsensitive)== 2){
qstr_textLine.prepend("'");
qstr_textLine.append("'");
int sqlbool=insertquery.exec("INSERT INTO testtbl (field1,field2,field3) "
"VALUES ("+qstr_textLine+")");
}
Yeah, definitely look at QSqlQuery::prepare()!