<?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[What is the connection string for connecting to local db file (.mdf)]]></title><description><![CDATA[<p dir="auto">I use the following connection string to connect to database in the sqlserver instance SQLEXPRESS:</p>
<pre><code>QString connStr = "DRIVER={SQL SERVER};SERVER=.\\SQLEXPRESS;DATABASE=dbName;";
</code></pre>
<p dir="auto">But I want now to connect to SQL Server database file (.mdf) and I already installed Microsoft SQL Server 2016 LocalDB. What connection string should I use?</p>
<p dir="auto">I tried the following connection string:</p>
<pre><code>QString connStr = "DRIVER={SQL SERVER};SERVER=%1;AttachDbFileName=%2;"
db.setDatabaseName(connStr.arg("(LocalDB)\\v11.0",dbFilename));
</code></pre>
<p dir="auto">And I also tried a different server:</p>
<pre><code>db.setDatabaseName(connStr.arg("(LocalDB)\\MSSQLLocalDB",dbFilename));
</code></pre>
<p dir="auto">But none of them works and throw the same error:</p>
<pre><code>"[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). QODBC3: Unable to connect"
</code></pre>
]]></description><link>https://forum.qt.io/topic/90641/what-is-the-connection-string-for-connecting-to-local-db-file-mdf</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 11:23:25 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/90641.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 12 May 2018 06:27:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to What is the connection string for connecting to local db file (.mdf) on Fri, 01 Jun 2018 16:00:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> said in <a href="/post/457807">What is the connection string for connecting to local db file (.mdf)</a>:</p>
<blockquote>
<p dir="auto">Hi<br />
Im not sure ODBC likes LocalDB</p>
<p dir="auto"><a href="https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f21d9354-01f1-484d-b5f8-ea63e0ca76e5/odbc-driver-13-for-sql-server-localdb-problem?forum=SQLServer2016Preview" target="_blank" rel="noopener noreferrer nofollow ugc">https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f21d9354-01f1-484d-b5f8-ea63e0ca76e5/odbc-driver-13-for-sql-server-localdb-problem?forum=SQLServer2016Preview</a></p>
<p dir="auto">I wonder if that have been fixed with newer versions ?</p>
</blockquote>
<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a>  for your help,  I followed the link you provide and finally found a solution to my problem, I put the solution <a href="https://stackoverflow.com/questions/50197722/what-is-the-connection-string-to-connect-to-local-db-file-mdf" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
]]></description><link>https://forum.qt.io/post/461434</link><guid isPermaLink="true">https://forum.qt.io/post/461434</guid><dc:creator><![CDATA[AK-47]]></dc:creator><pubDate>Fri, 01 Jun 2018 16:00:10 GMT</pubDate></item><item><title><![CDATA[Reply to What is the connection string for connecting to local db file (.mdf) on Sat, 12 May 2018 09:30:43 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
Im not sure ODBC likes LocalDB</p>
<p dir="auto"><a href="https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f21d9354-01f1-484d-b5f8-ea63e0ca76e5/odbc-driver-13-for-sql-server-localdb-problem?forum=SQLServer2016Preview" target="_blank" rel="noopener noreferrer nofollow ugc">https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f21d9354-01f1-484d-b5f8-ea63e0ca76e5/odbc-driver-13-for-sql-server-localdb-problem?forum=SQLServer2016Preview</a></p>
<p dir="auto">I wonder if that have been fixed with newer versions ?</p>
]]></description><link>https://forum.qt.io/post/457807</link><guid isPermaLink="true">https://forum.qt.io/post/457807</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sat, 12 May 2018 09:30:43 GMT</pubDate></item></channel></rss>