1

In ASP.Net, referencing my Access database from My Computer can be done like below:

Dim cn As New OleDbConnection("Provider = Microsoft.JET.OLEDB.4.0;" & "Data Source = C:/Class.mdb")

If I were to put it into my project App_data folder, how do I reference it?

Cloud S
  • 15
  • 5

2 Answers2

1

I believe what you want is the DataDirectory. Your string would look like so:

"Provider=Microsoft.JET.OLEDB.4.0;Data Source=|DataDirectory|\Class.mdb"

More connection strings here.

Doozer Blake
  • 7,677
  • 2
  • 29
  • 40
0

Sure, you can use the following format: Data Source=|DataDirectory|Foobar.sdf. See this question for details - Where is the SQL Server Compact file?

Community
  • 1
  • 1
Sergey Rybalkin
  • 3,004
  • 22
  • 26