dotnetnoob
dotnetnoob

Reputation: 11330

How do I map my connection string to my app_data folder rather than use an absolute path?

I have a connection string that includes the absolute path to my database.

Here's my connection string:

// removed

I have 2 questions:

  1. How do I convert the absolute path to look at my app_data folder instead of adding a full string?
  2. Is this a good /bad thing to do?

Thanks in advance.

Upvotes: 0

Views: 423

Answers (1)

Richard Deeming
Richard Deeming

Reputation: 31198

You should be able to use the |DataDirectory| substitution string:

AttachDbFilename=|DataDirectory|MyDb.mdf

MSDN Link

Upvotes: 1

Related Questions