PDA

View Full Version : Sqlite e QT4



vinny gracindo
27th October 2009, 15:39
Hi Well I wonder to what extent should I save the database (. Sqlite,. Dat,. Sql)? And there's no User or password, which I put in these fields?

I'm using QT4 and SQLite. OS: Windows

thanks.


void Principal::conectarBanco()
{
bancoDeDados = QSqlDatabase::addDatabase("QSQLITE");
bancoDeDados.setDatabaseName("sistema-transporte-db.dat");
bancoDeDados.setHostName("localhost");
bancoDeDados.setPassword("");
bancoDeDados.setUserName("");
bool ok = bancoDeDados.open();
if(!ok)
QMessageBox::critical(0, "Driver Sql Lite", tr("Driver Not Found"));
}

Lykurg
27th October 2009, 15:44
what extent should I save the database (. Sqlite,. Dat,. Sql)?

It doesn't matter. Name the file how ever you like. I personally use *.db.


And there's no User or password
because sqlite doesn't support users and passwords. So just skip that lines.


EDIT: also skip the host. It isn't needed either.