QT读取SQLserver数据库

QT框架读取目标数据库

#include "mainwindow.h"

#include "mainwindow.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include <stdio.h>

bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("182.151.6.159");
db.setPort(3306);
db.setDatabaseName("BDUMeauData");
db.setUserName("sa");
db.setPassword("MRznkj136");
db.setDatabaseName("SELECT*FROM dbo.BDU_3测试");
bool ok = db.open();
if (ok)
{
qDebug() << "连接成功" ;
}
else
{
qDebug() << "连接失败" ;
}
return 1;
}

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if (!createConnection())
return 1;
return a.exec();
}

15:23:18: Starting F:\c++Learn\build-ReadMysql-Desktop_Qt_5_12_11_MinGW_64_bit-Release\release\ReadMysql.exe ...
[LspTrace]process path is F:\c++Learn\build-ReadMysql-Desktop_Qt_5_12_11_MinGW_64_bit-Release\release\ReadMysql.exe

[LspTrace]ReadAccConfig returns false!

[LspTrace]FindMatchingProvider: inInfo is one of the LSPs entry.
[LspTrace]WSPStartup end: 0, protocol=6, [not] hook
连接失败

15:23:18: Starting F:\c++Learn\build-ReadMysql-Desktop_Qt_5_12_11_MinGW_64_bit-Release\release\ReadMysql.exe ...
[LspTrace]process path is F:\c++Learn\build-ReadMysql-Desktop_Qt_5_12_11_MinGW_64_bit-Release\release\ReadMysql.exe

[LspTrace]ReadAccConfig returns false!

[LspTrace]FindMatchingProvider: inInfo is one of the LSPs entry.
[LspTrace]WSPStartup end: 0, protocol=6, [not] hook
连接失败
抄的代码,不知道QT怎么读取数据库
帮助解决怎么读