Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

QSQL: Data source name too long QODBC3: Unable to connect

$
0
0
Hello, I’m very new to database programming and seem to have a problem getting my db to connect. I’m not even sure if my project can even find it. I was wondering if you could help me. I get the error: [Microsoft][ODBC Driver Manager]Data source name too long QODBC3: Unable to connect My db file name is “SpellingWords.sdf” I kind of followed along with a tutorial but was still pretty confused on how i make the database info match mine. I am using SQL Server 2008 Compact Edition. WordEditor::WordEditor(QWidget *parent) : QDialog(parent), ui(new Ui::WordEditor) {     ui->setupUi(this);     QString servername = "LocalHost\\SQLEXPRESS";     QString dbname = "SpellingWords";     QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");     db.setConnectOptions();     //QString dsn = QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;").arg(servername).arg(dbname);     QString dsn = QString("..\\..\\SpellingBee\\SpellingWords.sdf");     db.setDatabaseName(dsn);       if(db.open())     {       QMessageBox mBox;       mBox.setText("Open!");       mBox.exec();    }    else    {       QMessageBox mBox;       mBox.setText(db.lastError().text());       mBox.exec();    } }

Viewing all articles
Browse latest Browse all 13965

Trending Articles