Please nominate your Qt Champions for 2021!


  • I am trying to connect to a data base table I already made in Microsoft SQL Server Management Studio Express with Microsoft SQL Server 2005. This is how I am connectiong to it
    @QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    if (! {
    QMessageBox::warning(0, QObject::tr("Database Error"),
    return false;
    return true;@

    I am not getting a connection error anymore so I think it is connecting to the Data source fine but I can't figure out how to specify the specific database and table to get the information from. I know its there and has some informaiton in it because I ran the sqlbrowser demo and it connected to the correct database without me specifyting it (I assume because it is set as the default database) and then when I opened the table it had the information in it.

    Can anyone tell me how to do this? Also could anyone tell me how to print it out to the screen in a table like form, I am following the guidelines of an example that used SQLITE so maybe its different and thats why?

  • Thanks! I acctually figured it out by adding the username and password into so it was"username", "password") I thought that using the 2 statements above that line would have taken care of that but apparently not.

Log in to reply