<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can not connect Qt5.3.1 with MS SqlServer 2008R2.]]></title><description><![CDATA[<p dir="auto">hi,<br />
I'm connecting  Qt5.3.1 with MS SQL SERVER 2008R2 in Win 7, as following :-<br />
@<br />
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");</p>
<p dir="auto">QString dsn = QString("Driver=(SQL SERVER);SERVER=localhost\MSSQLSERVER;DATABASE=test_database;UID=sa;PWD=SA$Admin;");</p>
<pre><code>db.setDatabaseName(dsn);
</code></pre>
<p dir="auto">bool test;<br />
test = db.isValid();</p>
<pre><code>   if (test) //true
     QMessageBox::information(this,"ODBC Connectivity","database is valid");

   test = db.isDriverAvailable("QODBC3");

   if ( test ) //true 
     QMessageBox::information(this,"ODBC driver availbility","driver is available");


if(db.open())
{
    QMessageBox::information(this,"test_database","database opened");
    db.close();
}
else
{
    QMessageBox::information(this,"test_database",db.lastError().text());
}
</code></pre>
<p dir="auto">@</p>
<p dir="auto">[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connects</p>
<p dir="auto">and to display driveres availablability with this code to on messagebox :-</p>
<p dir="auto">@<br />
QStringList strlist = QSqlDatabase::drivers();<br />
int i = 1;<br />
QString str2 = "";<br />
QString str = "";</p>
<pre><code>foreach (str, strlist)
    str2 += "  " + QString::number(i++) + ".  " + str;

 QMessageBox::information(this,"test_database",str2);
</code></pre>
<p dir="auto">@</p>
<p dir="auto">I found this message :-</p>
<ol>
<li>QSQLITE  2. QMYSQL 3. QMYSQL3  4. QODBC  5. QODBC3  6. QPSQL  7. QPSQL7</li>
</ol>
<p dir="auto">Where am I going wrong. Please tell me how to connect.</p>
]]></description><link>https://forum.qt.io/topic/48281/can-not-connect-qt5-3-1-with-ms-sqlserver-2008r2</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 08:18:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/48281.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 Nov 2014 14:15:44 GMT</pubDate><ttl>60</ttl></channel></rss>