views:

692

answers:

2

Hello all. Thanks for the help, in advance.

Solution
-- WorkflowProject
  -- Workflow1
  -- Workflow2
-- WebProject (WAP)
  -- App_Data
    -- MyDatabase.vdb3
  -- MyWebService.asmx
  -- Web.Config

Ok, so.. that's the basic "outline" of the project. The database, is stored in the website, and is a VistaDB database (this could also be an MSAccess or SQLite Database). In the website, I could code against the database. I might have |DataDirectory| in my connection string.

The WORKFLOW project is separate from the Website. The MyWebService.asmx is a "stub" for calling the Workflow based web service.

*How do I open the database in the website App_Data directory ? Right now, I have the value hardcoded (i.e., @"E:\datadirectory\database.vdb3"), but this is not preferred and would only work on my development machine.*

I can't even pass in the location of the database, since the webservice (the .asmx file) is only 1 line, and is stub code for getting the caller into the workflow. I'm really at a loss as how to proceed.

Solution ? Best practices ? Links ?

Thank you!

+1  A: 

You should take a look at "VirtualPathUtility"

substitute the result of:

VirtualPathUtility.ToAbsolute("~/App_Data/db.vdb3");

into your connection string.

Andrew Theken
A: 

I wasn't able to get VirtualPathUtility to work. Here's the solution that I ended up finding that worked:

string s = AppDomain.CurrentDomain.GetData("DataDirectory") as string;

That gets the absolute path to the App_Data directory.

Matthew M.
I'd be curious to see the code that you used with VirtualPathUtility, and what error you received, just for my own edification.
Andrew Theken