destory27
destory27
2017-12-17 03:02

Qt5.4.1 无法连接SqlServer

5
  • qt5
  • sql

QSqlDatabase db;

QString servername="(local)";

QString dbname="QtSqlTest";
db = QSqlDatabase::addDatabase("QODBC");

QString dsn=QString("DRIVER={SQL SERVER};SERVER=%1;DATABASE=%2;").arg(servername).arg(dbname);

db.setDatabaseName(dsn);

db.setUserName("sa");

db.setPassword("123456");


    ![图片说明](https://img-ask.csdn.net/upload/201712/17/1513484542_656481.png)
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答

为你推荐