Creating OLEDB connection with ASP.NET VBhttp://forums.asp.net/t/1737790.aspx/1?Creating+OLEDB+connection+with+ASP+NET+VBThu, 10 Nov 2011 05:40:47 -050017377904673312http://forums.asp.net/p/1737790/4673312.aspx/1?Creating+OLEDB+connection+with+ASP+NET+VBCreating OLEDB connection with ASP.NET VB <p>I'm trying to connect an Access DB with the function beyond. &quot;Invalid path&quot; is the result. My Access database is saved in my project file in the map App_Data. What is the correct path to access the db?</p> <p>Thanks!</p> <pre class="prettyprint">Public Class DataManager Public Shared Function GetConnection() As OleDbConnection Dim conString As String = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=~/App_Data/payables.accdb&quot; Dim con As New OleDbConnection(conString) Return con End Function</pre> <pre class="prettyprint">End Class</pre> 2011-11-08T14:29:52-05:004673598http://forums.asp.net/p/1737790/4673598.aspx/1?Re+Creating+OLEDB+connection+with+ASP+NET+VBRe: Creating OLEDB connection with ASP.NET VB <p>I believe the OLEDB provider needs a windows path, e.g. &quot;c:\blah\yourproject\app_data\payables.accdb&quot;.&nbsp; Try this...</p> <p></p> <pre class="prettyprint">Dim conString As String = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; &#43; server.mappath(&quot;~/App_Data/payables.accdb&quot;) good luck</pre> 2011-11-08T17:59:01-05:004673682http://forums.asp.net/p/1737790/4673682.aspx/1?Re+Creating+OLEDB+connection+with+ASP+NET+VBRe: Creating OLEDB connection with ASP.NET VB <p>When using an accdb file (Access 2007 and higher), you need to use the new ACE 12.0 OleDb&nbsp;driver, which isn't installed by default on Windows Servers, so make sure it is available in your production environment. When it is not avalaible, create an mdb file instead. To reference files in the App_Data folder, the easiest way is to use the DataDirectory Directive:<br> <br> Dim conString As String = &quot;Provider=Microsoft.<strong>ACE.OleDb.12.0</strong>;Data Source=<strong>|DataDirectory|</strong>payables.accdb&quot;</p> <p>Dim conString As String = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<strong>|DataDirectory|</strong>payables.<strong>mdb</strong>&quot;</p> <p><a href="http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET">http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET</a><br> <br> </p> 2011-11-08T19:07:49-05:004676313http://forums.asp.net/p/1737790/4676313.aspx/1?Re+Creating+OLEDB+connection+with+ASP+NET+VBRe: Creating OLEDB connection with ASP.NET VB <p>No:)</p> <p>I'm afraid App_Data is a very typical folder that cannot be accessed directly because of its being too special...</p> <p>Try<span style="text-decoration:underline"><strong> |DataDirectory|</strong></span> instead</p> <p>&nbsp;<span class="typ">Dim</span><span class="pln"> conString </span><span class="typ">As</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source<span style="text-decoration:underline"><strong>=|DataDirectory|\payables.accdb</strong></span>&quot;</span><span class="pln"> <br> </span></p> 2011-11-10T01:28:55-05:004676626http://forums.asp.net/p/1737790/4676626.aspx/1?Re+Creating+OLEDB+connection+with+ASP+NET+VBRe: Creating OLEDB connection with ASP.NET VB <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Decker Dong - MSFT</h4> <p></p> <p>No:)</p> <p>I'm afraid App_Data is a very typical folder that cannot be accessed directly because of its being too special...</p> <p></p> </blockquote> <p></p> <p>There's nothing special about the App_Data folder when you want to access it through code, server.Mappath will work just fine. The only thing special on this folder is that all files are protected form being accessed directly through a web browser....</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Decker Dong - MSFT</h4> Try<span style="text-decoration:underline"><strong> |DataDirectory|</strong></span> instead</blockquote> <p></p> <p>Once again, you're repeating what I already said days ago....</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Decker Dong - MSFT</h4> <span class="typ">Dim</span><span class="pln"> conString </span><span class="typ">As</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source<span style="text-decoration:underline"><strong>=|DataDirectory|\payables.accdb</strong></span>&quot;</span><span class="pln"> <br> </span></blockquote> <p></p> <p>If you would read my previous reply, you'll see that this won't work....</p> 2011-11-10T05:40:47-05:00